【问题标题】:"unique" Filter is not working in AngularJs ng-repeat“唯一”过滤器在 AngularJs ng-repeat 中不起作用
【发布时间】:2016-11-23 09:01:18
【问题描述】:

我正在尝试使用unique下面的过滤器

<ng-repeat="feature in allfeatures | unique:'featureName'" value="{{feature.featureName}}">{{feature.featureName}}>

但它给了我这样的错误,

错误:[$injector:unpr] http://errors.angularjs.org/1.3.15/$injector/unpr?p0=uniqueFilterProvider%20%3C-%20uniqueFilter

<select id="selectFeature" ng-model="features" 
ng-required="true" 
multiple class="form-control" onchange="angular.element(this).scope().populateAllFeaturesT‌​axonomy(this)" style="width: 200px;"> 
<option ng-repeat="feature in allfeatures | unique:'featureName'" value="{{feature.featureName}}">{{feature.featureName}}</opt‌​ion> 
</select>

【问题讨论】:

标签: angularjs html


【解决方案1】:

我使用相同的 AngularJs @1.3.15 和 ui-bootstrap @0.13.3 并且有同样的问题。这可能是因为我使用的是旧版本的 ui-bootstrap,因为当我检查时它当前是 @ 1.3.3。

他们在另一个 SO post here. 中对此进行了修复

按照 angular-filter 的安装指南,确保将其包含在 app.module 主文件夹和 index.html 中。

这是我如何使用它的示例:

<th> Table Header </th>
<tr ng-repeat="patient in patients | unique: 'patient.name'" >
   <td> {{ patient.name }} , {{ patient.doctor }} </td>
</tr>

【讨论】:

  • 一般来说,你不应该只发布链接的答案。除了链接之外,发布一些相关代码
  • 重新阅读并包含我认为更有帮助的内容:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-01
  • 1970-01-01
  • 2016-02-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多