angular - Renderer2 启用/禁用 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
theElementRef
和 the nativeElement
,似乎没有任何效果
解决方案
如果你改变ElementRef
或MatRadioButton
它MatRadioButtonGroup
工作
此代码无需渲染即可工作
constructor(public renderer: Renderer2) {}
@ViewChild('voice_card_choices') voiceCardChoices: MatRadioButton || ElementRef ;
functionToDisableDropDown() {
this.voiceCardChoices.disabled = true;
}
希望有用
推荐阅读
- oracle - 调用 P_AA 时参数的数量或类型错误
- javascript - XML 显示 ["num_rows"]=> int(0)
- oracle - 如何在弹出窗口中执行和获取光标输入?
- c# - 恒定和静态场
- tensorflow-lite - 是否可以训练具体功能?
- java - 初始化整数被称为 charAt 的索引值,但是我不能减少索引整数的值
- javascript - 如何使用 gatsby-image 显示图像而不进行裁剪?
- centos - 在centos 7上安装gitlab后出现错误422
- php - require_once 没有在 PHP 中加载文件
- jsf - p:commandLink actionListener 切换到 Primefaces 7.0 后不再调用