| 98 | imports: [NgTemplateOutlet, CdkObserveContent], |
| 99 | }) |
| 100 | export class MatListOption extends MatListItemBase implements ListOption, OnInit, OnDestroy { |
| 101 | protected _selectionList = inject<SelectionList>(SELECTION_LIST); |
| 102 | private _changeDetectorRef = inject(ChangeDetectorRef); |
| 103 | |
| 104 | @ContentChildren(MatListItemLine, {descendants: true}) _lines!: QueryList<MatListItemLine>; |
| 105 | @ContentChildren(MatListItemTitle, {descendants: true}) _titles!: QueryList<MatListItemTitle>; |
| 106 | @ViewChild('unscopedContent') _unscopedContent!: ElementRef<HTMLSpanElement>; |
| 107 | |
| 108 | /** |
| 109 | * Emits when the selected state of the option has changed. |
| 110 | * Use to facilitate two-data binding to the `selected` property. |
| 111 | * @docs-private |
| 112 | */ |
| 113 | @Output() |
| 114 | readonly selectedChange: EventEmitter<boolean> = new EventEmitter<boolean>(); |
| 115 | |
| 116 | /** Whether the label should appear before or after the checkbox/radio. Defaults to 'after' */ |
| 117 | @Input() togglePosition: MatListOptionTogglePosition = 'after'; |
| 118 | |
| 119 | /** |
| 120 | * Theme color of the list option. This sets the color of the checkbox/radio. |
| 121 | * This API is supported in M2 themes only, it has no effect in M3 themes. For color customization |
| 122 | * in M3, see https://material.angular.dev/components/list/styling. |
| 123 | * |
| 124 | * For information on applying color variants in M3, see |
| 125 | * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants |
| 126 | */ |
| 127 | @Input() |
| 128 | get color(): ThemePalette { |
| 129 | return this._color || this._selectionList.color; |
| 130 | } |
| 131 | set color(newValue: ThemePalette) { |
| 132 | this._color = newValue; |
| 133 | } |
| 134 | private _color: ThemePalette; |
| 135 | |
| 136 | /** Value of the option */ |
| 137 | @Input() |
| 138 | get value(): any { |
| 139 | return this._value; |
| 140 | } |
| 141 | set value(newValue: any) { |
| 142 | if (this.selected && newValue !== this.value && this._inputsInitialized) { |
| 143 | this.selected = false; |
| 144 | } |
| 145 | |
| 146 | this._value = newValue; |
| 147 | } |
| 148 | private _value: any; |
| 149 | |
| 150 | /** Whether the option is selected. */ |
| 151 | @Input() |
| 152 | get selected(): boolean { |
| 153 | return this._selectionList.selectedOptions.isSelected(this); |
| 154 | } |
| 155 | set selected(value: BooleanInput) { |
| 156 | const isSelected = coerceBooleanProperty(value); |
| 157 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…