Ng-重复:按唯一性过滤 [英] Ng-Repeat: Filter By Uniqueness

查看:76
本文介绍了Ng-重复:按唯一性过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我已安装ui-boostrap,但浏览器向我显示错误Error: [$injector:unpr] Unknown provider: uniqueFilterProvider <- uniqueFilter

Though I have ui-boostrap installed, the browser shoots me an error Error: [$injector:unpr] Unknown provider: uniqueFilterProvider <- uniqueFilter

json对象

{ 
"_id" : ObjectId("55b81956fde835be46f22294"), 
"life" : true, 
"domain" : { "hidden" : true, "name" : "Eukarya" }, 
"kingdom" : { "hidden" : true, "name" : "Animalia" }, 
"phylum" : { "hidden" : true, "name" : "Chordata" }, 
"klass" : { "hidden" : true, "name" : "Mammalia" }, 
"order" : { "hidden" : true, "name" : "carnivoria" }, 
"family" : { "hidden" : true, "name" : "herpestidae" }, 
"genus" : { "hidden" : true, "name" : "galerelaa" }, 
"species" : { "hidden" : true, "name" : "Mongoose" }, 
"photo" : { "hidden" : true, "url" : "http://room909.com/wp-content/gallery/drawings-by-jared-flynn/snake-v-mongoose-web.jpg" }, 
"__v" : 0 
}

{ 
"_id" : ObjectId("55b81956fde835be46f22295"), 
"life" : true, 
"domain" : { "hidden" : true, "name" : "Eukarya" }, 
"kingdom" : { "hidden" : true, "name" : "Animalia" }, 
"klass" : {"name": "Bivalvia", "hidden": true},
"order" : { "hidden" : true, "name" : "Ostreoida" }, 
"family" : {"name": "Ostreidae", "hidden": true},
"genus" : { "hidden" : true, "name" : "" }, 
"species" : { "hidden" : true, "name" : "" }, 
"photo" : { "hidden" : true, "url" : "http://a-z-animals.com/media/animals/images/470x370/oyster5.jpg" }, 
"__v" : 0 
}

html

<section class="footer">
  <div id="explanation" class="container">
    <div ng-repeat="animal in animals | unique: 'animal.domain'" ng-hide="domain" class="panel panel-default">
      <p  class="panel-body">{{animal.domain.name}}</p>
    </div>
  </div>
</section>

我还尝试过对唯一值的变化,例如domain.namedomain,但是它们都带来相同的错误.

I've also tried variations on the unique's value like domain.name and domain, but they all bring the same error.

推荐答案

我找到了答案.相反,我们要做的就是简单地安装奇妙的,天才的,不可替换的 a8m angular -带有bower/npm的过滤器库,添加到我的依赖项数组(@Joy)中,并使用了语法ng-repeat="animal in animals | unique: 'domain.name'",一切正常.

I found an answer. All we have to do is, instead, simply installed the wonderful, genius, un-replaceable a8m angular-filter library with bower/npm, added to my array of dependencies (@Joy), and used the syntax ng-repeat="animal in animals | unique: 'domain.name'" and everything works fine.

这篇关于Ng-重复:按唯一性过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆