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

后端 未结 27 859
感动是毒
感动是毒 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 08:47

    You can use ng-options to achieve select tag binding to value and display members

    While using this data source

    countries : [
                  {
                     "key": 1,
                     "name": "UAE"
                 },
                  {
                      "key": 2,
                      "name": "India"
                  },
                  {
                      "key": 3,
                      "name": "OMAN"
                  }
             ]
    

    you can use the below to bind your select tag to value and name

    
    

    it works great

提交回复
热议问题