我有這個在我的指令,名爲 'BGCOLOR':Angular2 ElementRef nativeElement檢查是否元素被禁用
export class BgColorDirective {
constructor(el: ElementRef) {
console.log(el.nativeElement.disabled); // show "false"
if (el.nativeElement.disabled) {
el.nativeElement.style.backgroundColor = '#5789D8';
el.nativeElement.style.color = '#FFFFFF';
}
}
在我的模板,我有:
<button (click)="submitData()" [disabled]="true" bgcolor [routerLink]="['Onboarding']"> </button>
我不understant爲什麼el.nativeElement.disabled
回報false