Here is what seems to be bothering a lot of people (including me). 這彷佛困擾了不少人(包括我)。 this
When using the ng-options
directive in AngularJS to fill in the options for a <select>
tag, I cannot figure out how to set the value for an option. 在AngularJS中使用ng-options
指令填寫<select>
標籤的選項時,我沒法弄清楚如何設置選項的值。 The documentation for this is really unclear - at least for a simpleton like me. 這方面的文檔真的不清楚 - 至少對像我這樣的傻瓜來講。 spa
I can set the text for an option easily like so: 我能夠像這樣輕鬆設置選項的文本: .net
ng-options="select p.text for p in resultOptions"
When resultOptions
is for example: 例如,當resultOptions
: code
[ { "value": 1, "text": "1st" }, { "value": 2, "text": "2nd" } ]
It should be (and probably is) the most simple thing to set the option values, but so far I just don't get it. 它應該(而且多是)設置選項值最簡單的事情,但到目前爲止我尚未獲得它。 文檔