http://plnkr.co/edit/fFSoLmPFDBfNc2oOczZr?p=preview
Directory Code
.directive('inputSelect', function() { return { templateUrl: 'someTemplate.html', restrict: 'E', scope: { ngModel: '=', ngChange: '&', options: '=' } }; })
Controller code
$scope.someFunction = function(name) { console.log(name) }; $scope.colors = [{ name: 'black', shade: 'dark' }, { name: 'white', shade: 'light', notAnOption: true }, { name: 'red', shade: 'dark' }];
Pattern code
<select ng-model="ngModel" ng-change="ngChange()" ng-options="option.name for option in options"> </select>
Code for using the directive
<input-select ng-model="someModel" ng-change="someFunction(someModel.name)" options="colors"></input-select>
So, the arguments passed to someFunction() are undefined or contain the correct value, the behavior is unexpected and random.
source share