默认的ng-selected选项在没有触摸的情况下不会出现在POST表格中

时间:2014-01-27 15:24:32

标签: javascript angularjs angularjs-directive angularjs-scope

我有一个选择列表,其中默认选择一个选项为ng-selected。 当选择默认选项值并通过post方法提交时,它不会出现在post变量中。当我更改为其他一些选项并返回时它工作正常。

<select class="form-control" ng-model="newItem.if_unmard_rsn">
   <option value="Under age" ng-selected="'Under Age'">Under Age
   </option>
   <option value="Health Issue">Health Issue
   </option>
   <option value="Economical Issue">Economical Issue
   </option>
   <option value="No reason">No Reason
   </option>
</select>

1 个答案:

答案 0 :(得分:0)

<select class="form-control" ng-model="newItem.if_unmard_rsn" ng-init="newItem.if_unmard_rsn='Under Age'">
  <option value="Under age" >Under Age
  </option>
  <option value="Health Issue">Health Issue
  </option>
  <option value="Economical Issue">Economical Issue
  </option>
  <option value="No reason">No Reason
  </option>