我无法使用renderer2禁用Angular Material的下拉选择框。以下是我的代码:
Component.html
<mat-select #exLoc (selectionChange)="someFun($event)" [(value)]="someVal">
<mat-option aria-selected="true" [value]="locVal" *ngFor="let location of locations">{{location.LocationName}}
</mat-option>
</mat-select>
Component.ts
constructor(public renderer: Renderer2) {}
@ViewChild('exLoc') exLoc: ElementRef;
functionToDisableDropDown() {
this.renderer.setAttribute(this.exLoc, 'disabled', 'true');
}
MatSelect
替代ElementRef
。 - undefined