Reputation: 20129
If I create a select using Angular such as so:
<select multiple ng-model="selection" ng-options="option.name for option in getOptions()"></select>
How can I add an ng-click
listener to each of the options? Is this possible, or would I have to just create the options myself using ng-repeat
?
Upvotes: 3
Views: 3352
Reputation: 5634
You can use ngChange directive:
<select multiple
ng-change="update_select()"
ng-model="selection"
ng-options="option.name for option in getOptions()"></select>
And in your controller:
$scope.update_select = function() {
console.log($scope.selection);
};
Upvotes: 6