Here is the code snippet I am working with:
<select class=" text-center form-control" name="custname"
ng-model="a.custid"
ng-init="devcustname[0].customer_name"
ng-change="fetchassocd(a)">
<option value="" selected="true">Please select a Customer name</option>
<option ng-repeat="a in devcustname | orderBy:['customer_name']"
value="{{a.customer_id}}">{{a.customer_name}}
</option>
</select>
I am trying to set the default value as devcustname[0].customer_name
. However, the ng-init directive seems to be causing some issues. Ideally, when devcustname[0].customer_name
is null or undefined, I would like the "Please select a Customer name" option to be displayed as default.
The challenge I am facing is that if I switch to using ng-options
, I lose the ability to display the "Please select a Customer name" message.