I have the following code:
<select ng-model="model.RemediationCredentials" name="remediationCredential" id="remediationCredential">
<option value="0">---</option>
<option ng:repeat="cred in credentialsList"
data-index="{{$index}}" value="{{cred.Value}}">{{cred.Key}}</option>
</select>
and credentialsList
looks like:
credentialsList = [ { Key: "Panda", Value: "Zoo: } ]
I think I need to use ng-repeat
vs ng-option
to do some basic things like the no selection and do the data-index
. However, when I try to set the model it doesn't work...
$scope.model.RemediationCredentials = "Zoo"
Any suggestions?
I have the following code:
<select ng-model="model.RemediationCredentials" name="remediationCredential" id="remediationCredential">
<option value="0">---</option>
<option ng:repeat="cred in credentialsList"
data-index="{{$index}}" value="{{cred.Value}}">{{cred.Key}}</option>
</select>
and credentialsList
looks like:
credentialsList = [ { Key: "Panda", Value: "Zoo: } ]
I think I need to use ng-repeat
vs ng-option
to do some basic things like the no selection and do the data-index
. However, when I try to set the model it doesn't work...
$scope.model.RemediationCredentials = "Zoo"
Any suggestions?
Share Improve this question asked Oct 23, 2013 at 18:55 amcdnlamcdnl 8,65813 gold badges65 silver badges104 bronze badges 1- Do you need the index attached to the element itself? Would obtaining the index upon selection change suffice? – Jonathan Palumbo Commented Oct 23, 2013 at 19:28
1 Answer
Reset to default 4use the Angular Select Directive:
http://docs.angularjs/api/ng.directive:select
Should look something more like this:
<select ng-model="model.RemediationCredentials" name="remediationCredential" id="remediationCredential" ng-options="cred.value as cred.key for cred in credentialsList">
<option value="0">---</option>
</select>