proposal: Can we have ngOnChanges in slide toggle to monitor dynamic toggle changes?
When changing the variable for the checked property, the toggle status should change correspondingly.
It doesn't change
when users toggle the slide-toggle, we would like to popup a modal and ask for comments. If users change their mind and hit cancel, we need to switch the slide toggle back to original status.
Hi @maxisam , I have the same issue today. Can you please tell me how did you fix the problem as I can see you closed the issue :)?
Thank you,
M茅lissa
It was actually dead simple. (change)="onHoldChanged($event)" Somehow I didn't read the document closely.
You can find it in the document here https://material.angular.io/components/slide-toggle/api
Oh actually my problem is a bit different then. I used the same method as you've just mentioned.
My problem is, in my function onHoldChanged, the checked value (true/false) of the slider does not change. The same if I try directly try to set the checked value, the slider does not "slide".
It works onInit, but not after.
I don't think you can do that. You might wanna double check the source code, but I think checked is not an observer, so set checked value dynamic doesn't work. You need to use
@ViewChild(MatSlideToggle) _SlideToggle: MatSlideToggle;
this._SlideToggle.toggle();
Oh thank you for the information! It works perfectly, thanks :)
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 don't think you can do that. You might wanna double check the source code, but I think
checkedis not an observer, so set checked value dynamic doesn't work. You need to use