[英]Renderer2 enable/disabled Mat-radio-button-group
我有一个以禁用状态开始的 mat-radio-button-group,并希望以编程方式更改禁用值
@ViewChild('voice_card_choices') voiceCardChoices: ElementRef;
this.renderer.setProperty(this.voiceCardChoices, 'disabled', false); // Doesn't work
this.voiceCardChoices.disabled = false; // Doesn't work, just creates a new property called disabled on the object
this.voiceCardChoices.nativeElement.disabled = false; //Doesn't work, same case as above
尝试同时使用Renderer2
和ElementRef
和nativeElement
,似乎没有任何效果
如果您将ElementRef
更改为MatRadioButton
或MatRadioButtonGroup
它工作
此代码无需渲染即可工作
constructor(public renderer: Renderer2) {}
@ViewChild('voice_card_choices') voiceCardChoices: MatRadioButton || ElementRef ;
functionToDisableDropDown() {
this.voiceCardChoices.disabled = true;
}
希望有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.