【问题标题】:ui-select without ng-repeat没有 ng-repeat 的 ui-select
【发布时间】:2016-07-29 21:44:47
【问题描述】:

我需要向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 angular-ui-select


    【解决方案1】:

    这是不可能的,因为ui-select-choices 需要repeat 属性,如the source 的第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

    【讨论】:

      猜你喜欢
      • 2017-11-24
      • 1970-01-01
      • 2017-02-15
      • 1970-01-01
      • 2018-04-15
      • 2017-02-25
      • 1970-01-01
      • 2016-09-23
      • 2016-08-28
      相关资源
      最近更新 更多