Below is a pretty straightforward setup for a form drop down list. However, the on-change
event refuses to fire... unless it's changed to ng-change
.
This had me stuck for about an hour, since we use the same setup elsewhere in our site (i.e. model property/list/on-change
directive) without fail.
I'm wondering what the difference is between on-change
and ng-change
and why one works in this instance and the other doesn't?
View
<select id="grArchive"
name="grArchive"
class="form-control"
options="userList"
ng-model="selectedUser"
ng-options="user as user.name for user in userList"
on-change="showSelected()">
</select>
Controller
scope.selectedUser = {};
scope.userList = [];
scope.showSelected = function(){
scope.columns = addColumns;
};
var loadUserList = function(data){
scope.userList = $.map(data, function(item){
return {id: item.id, name: item.firstName + ' ' + item.lastName};
});
}
Just in case: the user drop down populates as expected (screen shot below)