Трехсоставной чекбокс
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>Свойства
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | null | Name of the component. |
| label | string | null | Label of the checkbox. |
| disabled | boolean | false | When present, it specifies that the element should be disabled. |
| tabindex | number | null | Index of the element in tabbing order. |
| inputId | string | null | Identifier of the focus input to match a label defined for the component. |
| ariaLabelledBy | string | null | Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
| style | object | null | Inline style of the component. |
| styleClass | string | null | Style class of the component. |
| readonly | boolean | false | When present, it specifies that the component cannot be edited. |
| checkboxTrueIcon | string | pi pi-check | Specifies the icon for checkbox true value. |
| checkboxFalseIcon | string | pi pi-times | Specifies the icon for checkbox false value. |
События
| Name | Parameters | Description |
|---|---|---|
| onChange | event.originalEvent: Original browser event<br>event.value: Current value. | Callback to invoke on value change. |
Стилизация
| Name | Element |
|---|---|
| p-chkbox | Container element |
| p-tristatechkbox | Container element |
| p-chkbox-box | Container of icon. |
| p-chkbox-icon | Icon element. |