ui-select without ng-repeat



我需要在ui-select中添加两个选项,而不是使用repeat和数组,我认为如果在<ui-select-choices>中标记它们,代码会更清晰(参见下面的示例)。但它不起作用,如果这是可能的,有什么想法吗?

     <ui-select ng-model="formula.value">
         <ui-select-match>
            <span ng-bind="$select.selected.name"></span>
         </ui-select-match>
         <ui-select-choices>
             <span>AND</span>
             <span>OR</span>
         </ui-select-choices>
     </ui-select>

这是不可能的,因为ui-select-choices需要repeat属性,如源代码中的第21行所示。相反,以下标记有效并且不牺牲可读性,IMO:

<ui-select ng-model="formula.value" theme="bootstrap">
  <ui-select-match>{{ $select.selected }}</ui-select-match>
  <ui-select-choices repeat="choice in ['AND', 'OR']">
    <span>{{ choice }}</span>
  </ui-select-choices>
</ui-select>

Plunker

最新更新