Компоненты PrimeNG
TriStateCheckbox

Трехсоставной чекбокс

PrimeNG/TriStateCheckbox (opens in a new tab)

TriStateCheckbox используется для выбора в качестве значения "true", "false" или "null".

С чего начать

Подключите модуль

import { TriStateCheckboxModule } from 'primeng/tristatecheckbox';

В .ts файле

import { Component, OnInit } from '@angular/core';
 
@Component({
  selector: 'app-prime-tristatecheckbox',
  templateUrl: './prime-tristatecheckbox.component.html',
  styleUrls: ['./prime-tristatecheckbox.component.scss']
})
export class PrimeTristatecheckboxComponent implements OnInit {
 
  constructor() { }
 
  value: any;
 
  ngOnInit(): void {
  }
}

Встройте компонент с помощью тэга p-triStateCheckbox.

<p-triStateCheckbox [(ngModel)]="value"></p-triStateCheckbox>

TriStateCheckbox

<p-triStateCheckbox [(ngModel)]="value"></p-triStateCheckbox>

Свойства

NameTypeDefaultDescription
namestringnullName of the component.
labelstringnullLabel of the checkbox.
disabledbooleanfalseWhen present, it specifies that the element should be disabled.
tabindexnumbernullIndex of the element in tabbing order.
inputIdstringnullIdentifier of the focus input to match a label defined for the component.
ariaLabelledBystringnullEstablishes relationships between the component and label(s) where its value should be one or more element IDs.
styleobjectnullInline style of the component.
styleClassstringnullStyle class of the component.
readonlybooleanfalseWhen present, it specifies that the component cannot be edited.
checkboxTrueIconstringpi pi-checkSpecifies the icon for checkbox true value.
checkboxFalseIconstringpi pi-timesSpecifies the icon for checkbox false value.

События

NameParametersDescription
onChangeevent.originalEvent: Original browser event<br>event.value: Current value.Callback to invoke on value change.

Стилизация

NameElement
p-chkboxContainer element
p-tristatechkboxContainer element
p-chkbox-boxContainer of icon.
p-chkbox-iconIcon element.