I'm using material select component in my app. Sometimes I have set default value in mat-select. but selectionChange event not firing when set default value. I read the documentation, there were written
Event emitted when the selected value has been changed by the user.
Is there any way that I can trigger programmatically?
You could get a hold of an instance of MatSelect using a ViewChild/ContentChild and emit to selectionChange yourself, but it seems a little convoluted, because you know when the event is going to fire since you're the one setting the value.
selectionChange you cant use this by ViewChild/ContentChild
I am having the similar kind of problem.
I want to set Mat-Select value from code. And based on assigned drop down value I need to show hide few form fields. I am setting the Mat-Select value from .ts file on initialization. like this
this.myForm.controls.myControl.setValue(this.dd[1]);
This is setting the value in Mat-Select drop down but it is not triggering selectionChange event and hence not able to show/hide other fields. Also reactive form mat-select field is not dirty.
Please suggest if there is a way to achieve this.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I am having the similar kind of problem.
I want to set Mat-Select value from code. And based on assigned drop down value I need to show hide few form fields. I am setting the Mat-Select value from .ts file on initialization. like this
this.myForm.controls.myControl.setValue(this.dd[1]);
This is setting the value in Mat-Select drop down but it is not triggering selectionChange event and hence not able to show/hide other fields. Also reactive form mat-select field is not dirty.
Please suggest if there is a way to achieve this.