My directive usage code
<input-select ng-model="someModel" ng-change="someFunction()" options="countries"></input-select>
My directory code
.directive('inputSelect', function () { return { templateUrl: 'someTemplate.html', restrict: 'E', scope: { ngModel: '=', ngChange: '=' } }; });
My directive template
<select ng-model="ngModel" ng-init="ngModel " ng-options="option[optionId] as option[optionName] for option in options" ng-change="ngChange"> </select>
So, when the selected element is changed, the someFunction() function is called for an infinite time (although the change is performed only once), which must be changed so that someFunction() called only once ( someFunction() is a function in the volume of the controller in which it is used this directive)
[I tried using & and @ for the ngChange area type, someFunction() does not start when using them. ]
source share