I got TypeError: transclude is not a function and also can't able to bind select options value in select2 in angularjs

I got TypeError: transclude is not a function and also can't able to bind select options value in select2 in angularjs

我使用 angularjs 获得了一个用于 multi select2 下拉菜单的插件代码。它工作正常,除了选项值未绑定在 select 选项中,而 运行 我的代码。

我已经 link 编辑了下面的 plunker 演示,但是 plunker 中的代码执行得很好,没有任何错误,但是我在 运行 使用我的代码时不知何故遇到了这个错误...

控制台错误:

**"TypeError: transclude is not a function"**

笨蛋link:

http://plnkr.co/edit/juqoNOt1z1Gb349XabQ2?p=preview

下面是我的模块中包含的这个演示模块,

 var gateApp = angular.module('gateApp', ["demo","angucomplete"])

我正在与这个错误作斗争任何人都可以给我建议。

供您参考控制台中呈现的 HTML 代码:

<ul class="ui-select-choices ui-select-choices-content select2-results ng-scope" repeat="color in availableColors | filter:$select.search">
<li class="ui-select-choices-group" ng-class="{'select2-result-with-children': $select.choiceGrouped($group) }">  
 <div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label ng-binding ng-hide" ng-bind="$group.name">
</div>
<ul role="listbox" id="ui-select-choices-0" ng-class="{'select2-result-sub': $select.choiceGrouped($group),   'select2-result-single': !$select.choiceGrouped($group) }" class="select2-result-single"><!-- ngRepeat: color in $select.items -->

<!-- ngIf: $select.open -->
<li role="option" id="ui-select-choices-row-0-0" class="ui-select-choices-row ng-scope select2-highlighted" ng-class="{'select2-highlighted': $select.isActive(this), 'select2-disabled': $select.isDisabled(this)}" ng-repeat="color in $select.items" ng-if="$select.open" ng-click="$select.select(color,false,$event)"><div class="select2-result-label ui-select-choices-row-inner" uis-transclude-append="">
</div> 
</li><!-- end ngIf: $select.open -->
<!-- end ngRepeat: color in $select.items -->
<!-- ngIf: $select.open -->
<li role="option" id="ui-select-choices-row-0-1" class="ui-select-choices-row ng-scope" ng-class="{'select2-highlighted': $select.isActive(this), 'select2-disabled': $select.isDisabled(this)}" ng-repeat="color in $select.items" ng-if="$select.open" ng-click="$select.select(color,false,$event)">
</li><!-- end ngIf: $select.open --><!-- end ngRepeat: color in $select.items --><!-- ngIf: $select.open -->
</ul>
</li>
</ul>

angular 的版本可能太旧了。我在使用 v1.2.16 和 ui-select requires 1.2.18 minimum 时遇到了同样的问题。

https://github.com/angular-ui/ui-select/wiki/Getting-Started

我也遇到了这个错误。为我解决问题的方法是将 ng-if 从根元素中取出并将其放入需要它的子元素中。