0
我有对象在格式过滤通过对象数组
[1: {firstName: "Hello",
lastName: "World",
shortName: "h.world",
...some other items
},
2: {firstName: "John",
lastName: "Doe",
shortName: "j.doe",
...some other items
}]
阵列(〜650)而我需要通过基于文本输入,这应搜索firstName+ " "+lastName
列表进行过滤。所以搜索He
或Hello W
将返回Hello World
,并且搜索Hellow
不会返回它(大小写无关紧要)。过滤数组的最佳方法是什么?我已经看过安格拉斯过滤器的方法,但我还没有制定出如何做到这一点。
编辑我有什么
<div ng-controller="NotesCtrl">
<p>Search for a user to see there sessions and notes</p>
<input type="text" id="user" ng-model="search.firstName" />
{literal}
<ul>
<li ng-repeat="u in users | filter:search">{{u.activeDirectoryName}}</li>
</ul>
{/literal}
</div>
从我读过,应该工作,但是名单不进行过滤。我是否需要在控制器中做任何事情来实现这个目标?
答案:即使在PHP中,我的数据是一个数组,在JavaScript中它是一个对象,改变了一下,所以它作为一个数组来看,它似乎现在工作。
您可以尝试查看文档。这是非常直接的http://docs.angularjs.org/api/ng/filter/filter – Shanimal
我试过了文档说的,但列表不适合(看我的编辑) –
看看我对这个问题的回答http://stackoverflow.com/questions/13216115/filtering-by-multiple-specific-model-properties-in-angularjs/20272713#20272713 – NicolasMoise