I have an angular user edit page with a select box:
<select name="clientRole" ng-model="client.role" required>
<option value="{{client.role}}">{{client.role}}</option>
<option ng-repeat="role in roleOptions" value="{{role.name}}">{{role.name}}
</select>
The array "roleOptions" contains all of the possible roles. This page is used to edit a client, and the client will have a role already assigned. When the page comes up, I want the role that is assigned to the client to show as the default value. The way I have it above, the role is duplicated.
Does angular have a way that handles this, or do I need to edit the "roleOptions" array to delete the client role before the page is called?
ng-optionsalongside your select element instead ofng-repeatwith the option element. That way yourng-modelwill implicitly select the default value.