I'm trying to create my own component library for another CSS framework. So I studied the source code of Angular Material as an example. And then I came across this line:
@Component({
moduleId: module.id,
selector: `button[mat-button], button[mat-raised-button], button[mat-icon-button],
button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],
button[mat-flat-button]`,
exportAs: 'matButton',
host: {
'[disabled]': 'disabled || null', // This line!
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
},
templateUrl: 'button.html',
styleUrls: ['button.css'],
inputs: ['disabled', 'disableRipple', 'color'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MatButton extends _MatButtonMixinBase {
...
}
I just want to confirm my understanding, is the line I highlighted does not need to have || null
part?
My understanding is as follows: this component is bind to a HTMLButtonElement
, which has its own disabled
property. The boolean value can be passed to the element just fine.
Any answer would be appreciated. (Especially Kara, as it was you who introduced this line :P)