How do I set the value property in AngularJS' ng-options?

后端 未结 27 900
感动是毒
感动是毒 2020-11-22 08:17

Here is what seems to be bothering a lot of people (including me).

When using the ng-options directive in AngularJS to fill in the options for a &

27条回答
  •  一生所求
    2020-11-22 09:01

    How the value attributes gets its value:

    • When using an array as datasource, it will be the index of the array element in each iteration;
    • When using an object as datasource, it will be the property name in each iteration.

    So in your case it should be:

    obj = { '1': '1st', '2': '2nd' };
    
    
    

提交回复
热议问题