下面是完整的错误我得到的角UI选
Here is the full error I get in angular ui-select
Error: [$interpolate:interr] Can't interpolate: {{$select.getPlaceholder()}} TypeError: Cannot read property 'length' of undefined
我的标记是:
<ui-select multiple ng-model="case.keywords" theme="bootstrap">
<ui-select-match placeholder="Select keywords...">{{$item.name}}</ui-select-match>
<ui-select-choices repeat="keywords in keywords | filter: $select.search">
<div ng-bind-html="keyword.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
<p>Selected: {{case.keywords}}</p>
没有比 GET
其他控制器的特殊婷从数据库关键字的数组。显然 ngSanitize
和 ui.select
包含在模块依赖关系。
Nothing special in controller other than get
ting the array of keywords from db. Obviously ngSanitize
and ui.select
are included in the module dependencies.
另一个问题我是选择是不可见的。我可以显示所选的,但选择列表是不可见的。我使用的引导主题, select.css
引用。下面是它看起来像
The other issue I have is that choices are not visible. I am able to show the selected ones, but list of choices is not visible. I am using bootstrap theme, select.css
is referenced. Here's what it looks like
感谢您的帮助。
这@SunilVurity和@Fiver问题给我,导致我解决问题的提示:
Questions from @SunilVurity and @Fiver gave me hints that lead me to resolve the issue:
第一我改变了关键字
到中的关键字
:
<ui-select-choices repeat="keywords in keywords | filter: $select.search">
二在我的控制器我有
appFactory.getKeywords().then(function (keywords){
$scope.keywords = keywords;
$scope.case = {};
$scope.case.selectedKeywords = [];
});
这我更改为:
$scope.case = {};
$scope.keywords = [];
learningCasesFactory.getKeywords().then(function (keywords){
$scope.keywords = keywords;
$scope.case.selectedKeywords = [];
});
你可以在控制器中看到的, GET
函数是异步的,它返回一个未定义的列表,这引起我的问题提到的错误上载的看法。更新控制器的误差消失之后。这太问题帮助 AngularJS插值误差。
As you can see in the controller, the get
function is asynchronous which returns an undefined list to the view on load which caused the error I mentioned in the question. After updating the controller the error disappeared. This SO question helped AngularJS Interpolation Error.
第三的 uiselect
和角
版本可能导致的问题。我的角版本是1.2.9。这 UI的选择Github上的问题表明,升级版的角度解决问题,我把它升级到1.3.11
Third the uiselect
and angular
versions can cause issues. My angular version is 1.2.9. This ui-select Github issue shows that upgrading the angular version solves the issue, I upgraded it to 1.3.11
感谢@SunilVurity和@Fiver
Thanks @SunilVurity and @Fiver