When I connect ng-model to a controller scope variable, it does not update the view if changes are made in the controller variable. For example, I'm trying to find a way to initialize the "selected" listbox by doing the following:
<select
ng-options="e.displayName for e in job.allEmployees"
multiple
ng-model="job.allEmployeesOnJob"
bs-duallistbox
></select>
jobService.getEmployeesOnJob(job.jobId).then(
function(emps){
vm.allEmployeesOnJob = emps;
_.each(vm.allEmployeesOnJob, function(item, index, list){
item.displayName = item.firstName + " " + item.lastName + " - " + item.homeLocation.name;
});
}
)
The right side listbox should show the initialized list of employees but it does not. Then when I click an item from the left list, it moves to the right list but completely overwrites the "job.allEmployeesOnJob" variable. I believe this means two-way binding is not setup properly to ng-model because updates in the controller should be reflected on the DOM if it were.