javascript - Angular, boolean value in a select box -


i want set boolean value true or false using select here code:

<select class="span9" ng-model="proposal.formalstoryboard"> <option value="false">not included</option> <option value="true">included</option> </select> 

the value (proposal.formalstoryboard) set true or false but change not reflected on select box when value assigned.

i tried ng-value="true" , ng-value="false" instead of value it's not working well.

edit: commentors have pointed out original solution did not work claimed. have updated answer reflect correct answer given others below (i cannot delete accepted answer).

for angular 1.0.6, consider html:

<div ng-app="">   <div ng-controller="mycntrl">     <select ng-model="mybool"             ng-options="o.v o.n o in [{ n: 'not included', v: false }, { n: 'included', v: true }]">     </select>     <p>         selected: <b>{{ mybool }}</b> opposite: {{ !mybool }}    </p>   </div> </div> 

and javascript:

function mycntrl($scope) {     $scope.mybool = true; } 

here working demo angular 1.0.6 , here working demo angular 1.3.14, different.


Comments