0
votes

I have a mat-radio-button-group that starts of as disabled, and want to programatically change the disabled value

@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

Tried using both Renderer2 and just the ElementRef and the nativeElement, nothing seems to work

1

1 Answers

1
votes

If you change ElementRef to MatRadioButton or MatRadioButtonGroup it work

This code work without render

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

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

Hope useful