繁体   English   中英

Renderer2 启用/禁用 Mat-radio-button-group

[英]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

尝试同时使用Renderer2ElementRefnativeElement ,似乎没有任何效果

如果您将ElementRef更改为MatRadioButtonMatRadioButtonGroup它工作

此代码无需渲染即可工作

constructor(public renderer: Renderer2) {} 
@ViewChild('voice_card_choices') voiceCardChoices: MatRadioButton || ElementRef ; 

functionToDisableDropDown() {
  this.voiceCardChoices.disabled = true;
}

希望有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM