我无法动态启用/禁用autocomplete textfield component或其他方式。
我希望默认情况下禁用该组件。稍后在一些用户活动上,比如点击按钮,这应该启用该组件。
我尝试了以下代码,但没有工作:
export class MyComponent {
// this DIDN'T WORK
opts:object={value: "", disabled: true};
ctrl= new FormControl(this.opts);
ngDoCheck(){
// this DIDN'T WORK
// this could be ngOnChange, ngOnInit or button click event
if(this.IsTextBoxEnabled){
this.ctrl.enable();
}else{
this.ctrl.disable();
}
}
}
如何在Angular Material Autocomplete组件中执行此操作?
更新
Similar issue on SO也未得到答复。我回答了我的回答。
答案 0 :(得分:0)