且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

双向数据绑定在为选择二AngularJS不起作用

更新时间:2023-02-16 16:57:06

Angular-ui/ui-select2 GitHub的页面状态:

Angular-ui/ui-select2 github page states:

UI-SELECT2与&LT不相适应;选择NG-选项> 。为了获得***的
  结果使用<选项NG重复方式> 而不是

ui-select2 is incompatible with <select ng-options>. For the best results use <option ng-repeat> instead.

所以,为了保存自己头痛我也推荐使用带有NG-重复选项为:

So, to save yourself from headache I also recommend using options with ng-repeat as in:

$scope.filterItems = [
  {id: 1, text: 'Item1'},
  {id: 2, text: 'Item2'},
  {id: 3, text: 'Item3'},
  {id: 4, text: 'Item4'}
];

<select ui-select2 placeholder="All" ng-model="chosenItem">
  <option value=""></option>
  <option ng-repeat="item in filterItems" value="{{item.id}}">{{item.text}}</option>
</select>

DEMO PLUNKER