Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ng选项默认值始终为空_Angularjs_Ng Options - Fatal编程技术网

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">