Your provided code looks correct. You may have a problem elsewhere but you'd need to provide more detail before we could help. Here's a StackBlitz sample where [disabled]
is bound to a component property.
app.component.html
<select [disabled]="selectDisabled">
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
</select>
<input type="button" (click)="selectDisabled = !selectDisabled" value="Toggle">
app.component.ts
import { Component } from "@angular/core";
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
selectDisabled: boolean = true;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…