angular-ui-switch
angular-ui-switch copied to clipboard
ng-change adds parenthesis
Remove the () that are added on ng-change in line 12. Change
html += attrs.ngModel ? ' ng-click="' + attrs.ngModel + '=!' + attrs.ngModel + (attrs.ngChange ? '; ' + attrs.ngChange + '()"' : '"') : '';
to
html += attrs.ngModel ? ' ng-click="' + attrs.ngModel + '=!' + attrs.ngModel + (attrs.ngChange ? '; ' + attrs.ngChange + '"' : '"') : '';
This causes problems when the supplied ng-change is actually a function with supplied parameters. This problem came up when using the switch inside an ng-repeat section. The function supplied to ng-change needed to have a parameter with the specific item.
<div ng-repeat="item in items">
<switch name="isActive" ng-model="item.isActive" class="green" ng-change="activate(item);"></switch>
</div>
Awesome control. Thanks for putting it together.
meet this bug today