Open gldmtr opened 2 years ago
I don’t remember exactly. It might have been to set the initial value from ngModel on component init.
That probably makes sense to set an initial value but it causes some issues with side-effects being called even if a value haven't been changed.
Also experiencing the same problem.
I'm using this component to invoke an API based on the change
event. As of v10.0.1, it is triggering the change event on initialization, resulting in the API being called.
For Example, I have a settings page where toggling the ui-switch
will immediately call the API to disable functionality. If I use versions 10.0.1 or greater, then every time I open my settings page, it's toggling the change
event.
Any update on this? If you are calling an API on this load event, it can cause pretty wild issues. Any work arounds anyone has come up with?
Any update on this? If you are calling an API on this load event, it can cause pretty wild issues. Any work arounds anyone has come up with?
Not sure. I might revert the change in the commit mentioned in the first comment.
Hi @cmckni3, Are you planning to revert the changes becuase of which this intial load issue is appearing? I have used this package in my project and recently updated the version as well. Now I have to handle this inital load by adding some extra code. Let us know.
@cmckni3 I would suggest to revert that commit. Because there is another issue with this line of code. See https://github.com/webcat12345/ngx-ui-switch/issues/493
Hi. First of all - thank you for the library.
After update from version 10 to 12 I noticed that ngModelChange is triggered right after the ui-switch component appears on a page. It seems to be related to the commit https://github.com/webcat12345/ngx-ui-switch/commit/1382bb140422c5efca4df9d6e15030da3535c2e2 Could you please explain what was the fix about? Is it supposed to convert incoming non-boolean value into a boolean?
The issue example: https://stackblitz.com/edit/ngx-ui-switch-kz2sgk alert is called right after the page init.