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

后端 未结 27 1204
感动是毒
感动是毒 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:59

    To send a custom value called my_hero to the server using a normal form submit:

    JSON:

    "heroes": [
      {"id":"iron", "label":"Iron Man Rocks!"},
      {"id":"super", "label":"Superman Rocks!"}
    ]
    

    HTML:

    
    
    

    The server will receive either iron or super as the value of my_hero.

    This is similar to the answer by @neemzy, but specifying separate data for the value attribute.

提交回复
热议问题