Reputation: 1007
I have a dropdown like this:
<select data-ng-model="docPropIdentityModel.Status" class="form-control">
<option value="">-- None --</option>
<option value="1">Active</option>
<option value="0">Inactive</option>
</select>
I'm trying to set its value to a specific option as follows:
$scope.docPropIdentityModel.Status = 1;
I was expecting to set its value to 1, so that Active is shown as the dropdown option. But its not working.
Upvotes: 2
Views: 4000
Reputation: 113
In angularJS you want to binding select control than use dynamic populate select control. You are using static binding so this way you can`t able to select dynamic
$scope.docPropIdentityModel.Status = [{Id:'1',Name:'Active'},{Id:'2',Name:'Inactive'}]
<select data-ng-model="docPropIdentityModel.Status" name="statuss"
ng-options="status.Name for status in docPropIdentityModel.Status track by status.Id" required>
</select>
Upvotes: 1
Reputation: 25352
Your option's value type is string.
In order to make it selected, you have to provide a string type data.
try like this
$scope.docPropIdentityModel.Status="1";
Upvotes: 4