How to set parameter value using ng: Parameters

Apparently AngularJS cannot correctly build the list of items <option>

as a simple template in IE, so it provides a directive ng:Options

(see https://github.com/angular/angular.js/issues/235 ).

By looking at the source, I was able to plot the parameters with the shortcuts I needed like this ( JSFiddle ):

<!-- what I'd like to do -->
<select>
    <option ng:repeat='key in keys' value='{{key}}'> {{lookup[key].firstName}} {{lookup[key].lastName}} </option>
</select>
<br/>
<br/>
<!-- what Angular lets me do -->
<select ng-model='key' ng:options='k as lookup[k].firstName + " " + lookup[k].lastName for k in keys'></select>

      

However, when I check the Firebug parameters, I see that it is a numeric index, not my desired key value (I was hoping the initial k

would be used as the parameter value).

I haven't looked deeply into the code, so I don't know if there is another part of the expression that I am missing (the regex doesn't seem to contain any additional relevant keywords).

I was hoping that someone might know this directive well enough to tell me (1) how to do it, or (2) that I was out of luck.

+3


source to share


1 answer


Your desired key value is in the property that you set with ng-model, i.e. key

... Add {{key}}

to the end of your HTML (just after your last picklist) to see it.



As you discovered, Angular stores the array index in HTML. For more details see AngularJS - value attribute to select

+1


source







All Articles