angular-ui-switch icon indicating copy to clipboard operation
angular-ui-switch copied to clipboard

ng-change adds parenthesis

Open dhaub opened this issue 10 years ago • 1 comments

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.

dhaub avatar Mar 28 '15 17:03 dhaub

meet this bug today

Stupidism avatar Dec 04 '15 11:12 Stupidism