Angularjs ng选项默认值始终为空
我无法为我的选择设置默认值。它总是空白的。啊Angularjs ng选项默认值始终为空,angularjs,ng-options,Angularjs,Ng Options,我无法为我的选择设置默认值。它总是空白的。啊 <div ng-controller="quickComposeController"> <div id="QuickComposeEmail"> <form id="quickComposeForm"> <div class="modal-header"> <h3>Set email preferences&l
<div ng-controller="quickComposeController">
<div id="QuickComposeEmail">
<form id="quickComposeForm">
<div class="modal-header">
<h3>Set email preferences</h3>
</div>
<div class="modal-body">
<select ng-init="selected=selected[0]" ng-model="selected" ng-options="o.value as o.name for o in optionsObject">
</select>
</div>
<div class="modal-footer">
<input class="btn btn-success" type="submit" value="Compose Email">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</form>
</div>
</div>
我只是把这写在底部,因为stackoverflow告诉我我的帖子大部分是代码,我需要更多的文本。祝大家度过美好的一天 您的选择应该是:
<select ng-init="selected=selected[0].value" ng-model="selected" ng-options="o.value as o.name for o in optionsObject">
这是我的建议
需要注意的一点是,您不仅要指定正确的索引,还要指定其中的
值
属性,因为您的选项基于值
谢谢。。。为没有弄明白这一点而感到愚蠢。可能是重复的
<select ng-init="selected=selected[0].value" ng-model="selected" ng-options="o.value as o.name for o in optionsObject">