加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – ui-select error“无法插值:{{$select.getPlaceho

发布时间:2020-12-17 07:13:39 所属栏目:安全 来源:网络整理
导读:这是我在角度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="bootst
这是我在角度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>

除了从db获取关键字数组之外,控制器没什么特别之处.显然,ngSanitize和ui.select包含在模块依赖项中.

我遇到的另一个问题是选择不可见.我能够显示所选的,但选项列表不可见.我正在使用bootstrap主题,select.css被引用.这是它的样子

谢谢您的帮助.

解决方法

来自@SunilVurity和@Fiver的问题给了我一些提示,让我解决了这个问题:

首先,我更改了关键字关键字:

<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函数是异步的,它会在加载时向视图返回一个未定义的列表,这会导致我在问题中提到的错误.更新控制器后,错误消失.这个SO问题有助于AngularJS Interpolation Error.

第三,uiselect和angular版本可能会导致问题.我的角度版本是1.2.9. ui-select Github issue显示升级角度版本解决了问题,我将其升级到1.3.11

谢谢@SunilVurity和@Fiver

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读