使用ng-options angularJS添加静态选项

时间:2017-06-16 10:36:16

标签: angularjs

我在角度js的select元素中使用ng-options。并在select选择我只想在options.my code ===>

的开头添加一个额外的选项
<div class="form-group">
     <select class="form-control select2" ng-options="(o.fullName+' ('+o.email+')') for o in SubTeamUserList track by o.id" name="SelectedUserList" ng-model="SelectedUserList" multiple data-placeholder="Search By User" style="width: 100%;">
            <option value="" disabled>Select A User</option>
      </select>
</div>

enter image description here

那对我不起作用?我不知道为什么。然后我在网上搜索并找到一些像=&gt;的解决方案。 angularJS - add a Static option with ng-options Add two extra options to a select list with ngOptions on it Angular ng-options - Is there a way to add an option when the model contains a value not present in the options list?

在看到上述解决方案后,我尝试了=&gt;

     <div class="form-group">
        <select class="form-control select2" ng-options="" name="SelectedUserList" ng-model="SelectedUserList" multiple data-placeholder="Search By User" style="width: 100%;">
              <option value="" disabled>Select A User</option>
              <option ng-repeat="(o.fullName+' ('+o.email+')') for o in SubTeamUserList track by o.id">{{(o.fullName+' ('+o.email+')')}}</option>
        </select>
    </div>

这样做之后,这也显示了类似=&gt; enter image description here 但这也不适合我,我不知道为什么?任何人都可以帮助我吗?

0 个答案:

没有答案