如何在ui-select中更改ng-if到ng-show

时间:2017-04-20 09:45:19

标签: angularjs ui-select

enter image description here

    <div class="form-group">
        <label class="col-sm-3 control-label">toys</label>
        <div class="col-sm-7">
            <ui-select ng-model="VM.editData.toy" theme="selectize">
                <ui-select-match><span ng-bind="$select.selected.text"></span></ui-select-match>
                <ui-select-choices repeat="item.value as item in (VM.editConfig.toys | filter:$select.search)">
                    <span ng-bind="item.text"></span>
                </ui-select-choices>
            </ui-select>
        </div>
    </div>

我想使用ng-show not ng-if如果在选项标签内,因为我需要显示/隐藏这个dom而不是删除它。我该怎么办? 另外:angularjs - 1.4.8 ui-select - 0.13.2

1 个答案:

答案 0 :(得分:0)

查看此plunkr link ..
我刚刚从指令本身改变了它。现在,选项加载ng-show,而不是ng-if ..
在项目的附加select.js(ui-select dist文件)中, 搜索以下行,

 choices.attr('ng-repeat', parserResult.repeatExpression(groupByExp))
         .attr('ng-if', '$select.open'); 

 <abbr ng-if=\"$select.allowClear && !$select.isEmpty()\" 

现在将ng-if从这些行更改为ng-show,

 choices.attr('ng-repeat', parserResult.repeatExpression(groupByExp))
         .attr('ng-show', '$select.open'); 

 <abbr ng-show=\"$select.allowClear && !$select.isEmpty()\" 

多数民众赞成! For Reference