Utilizing a dropdown to display client names. Users have the ability to choose an existing client, which will then update the scope property:
Controller
Setting up the initial selection.
if($scope.clients.length > 0) $scope.existingClient = $scope.clients[0];
View
<select
id='nm-existing-client-name'
class='form-control input-lg'
ng-model='existingClient'
ng-options="client.name for client in clients">
</select>
The existingClient
scope property remains unchanged when the selection in the dropdown changes. Without initialization (removing the line from the controller above), the existingClient
value will remain undefined.
Adding an ng-change
will trigger an event when a new value is selected, but the model itself will not reflect the updated value.
This project uses AngularJS v1.2.0-rc.3.