angularjs - Angular.js selecting from a hash / object -
i have simple dropdown:
{{x}} <select ng-model="x" ng-options="k k in [1,2,3]"></select>
easy: {{x}} replaced selected value 1, 2 or 3.
but if info looks this?
<select ng-model="x" ng-options="k.a k in [{a:1},{a:2},{a:3}]">
i want ones, twos , threes depending on selection "{a:1}".
hm.. this suggests maybe won't want. ideas?
you're missing 1 piece.
if @ docs ng-options
, there several forms comprehension look can take.
the form have label value in array
. form, when take options, gives entire value of array item, in case {a: 1}
.
one of other forms can utilize select label value in array
. stick look in from, , result of that look bound model.
so like:
ng-options="k.a k.a k in [...]"
then you'll value of a
attribute of selected array item.
here's fiddle you.
angularjs
No comments:
Post a Comment