Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch-change should only fire if the switch itself changed the value #111

Closed
Deklin opened this issue May 21, 2016 · 5 comments
Closed
Labels

Comments

@Deklin
Copy link

Deklin commented May 21, 2016

Here is a plunkr showing the issue.
http://plnkr.co/edit/NYLyEUBz2fs3XFCKtCjS?p=preview

Basically lets compare ng-change to switch-change

ng-change only fires if the directive/controller managing the model makes the change, an outside change will not fire this

switch-change will fire if the model is changed even outside the angular-bootstrap-switch codebase.

@Deklin
Copy link
Author

Deklin commented May 21, 2016

In the plunkr you can compare the behavior between the checkbox and the switch itself.

@frapontillo
Copy link
Owner

According to the documentation, "switch-change evaluates an expression when the model value changes". I am not going to handle out-of-Angular events in an Angular directive.
ng-change will instead fire when the view value changes, according to the AngularJS spec.

You may want to read the discussion here.

@Deklin
Copy link
Author

Deklin commented May 21, 2016

I can't believe I missed the fact that ng-change works on this... !! For some reason I read switch-change as your implementation of ng-change and that I was to use that instead of ng-change.
Just tested ng-change on the plunkr and it works fine.

Thanks for your quick reply and feedback.

@tucq88
Copy link
Contributor

tucq88 commented Jun 3, 2016

Yeah, I was like @Deklin . I thought that ng-change & switch-change doing same thing. How stupid.
Maybe we should update this into the README so people might not misunderstand this anymore.

@frapontillo
Copy link
Owner

@tucq88 I will gladly accept PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants