Skip to content Skip to sidebar Skip to footer

How To Fix Unexpected Arguments Passing From A Function Being On Ng-change For Select List?

http://plnkr.co/edit/fFSoLmPFDBfNc2oOczZr?p=preview Directive code .directive('inputSelect', function() { return { templateUrl: 'someTemplate.html', res

Solution 1:

Your template should call a method by passing a parameter in JSON format like ng-change="ngChange({someModel: ngModel})" from directive

Make sure while calling function from directive you should pass parameter with the key should be function parameter name as here it is someModel and then pass the value like here its ngModel

Markup

<input-select ng-model="someModel" ng-change="someFunction(someModel)" options="colors"></input-select>

Directive template

<select ng-model="ngModel" ng-change="ngChange({someModel: ngModel})" 
  ng-options="option.name for option in options">
</select>

Working Plunkr

Post a Comment for "How To Fix Unexpected Arguments Passing From A Function Being On Ng-change For Select List?"