javascript - Passing value instead of whole object with ng-options -
i'm parsing .json file , showing available options in select:
<div bo-switch-when="dropdown"> <fieldset> <select ng-options="options.text option in question.body.options" ng-model="question.answer" ></select> </fieldset> </div>
it working, not want to. instead of getting whole object model, want have value of object. via chrome dev tools:
this object (as in picture) in model. i want have text.
but when change ng-options this:
ng-options="options.text option.text in question.body.options"
it isn't working @ all...
this pretty common question among angular developers.
you can use ng-repeat
, so:
<select ng-model="question.answer" > <option ng-repeat="option in question.body.options" value="{{option.text}}">{{option.text}}</option> </select>
Comments
Post a Comment