我有一个名为sports
的数组,json:
[
{
"id": 26,
"name": "LIVE Betting",
"priority": 0,
"leagues": []
},
{
"id": 8,
"name": "NBA",
"priority": 3,
"leagues": [
{
"id": 5932,
"parent": 1000,
"name": "NBA",
"sport": {
"id": 8,
"name": "NBA"
},
"lineType": "G",
"priority": [
1,
3
],
"part": "0"
}
]
},
{
"id": 24,
"name": "College Basketball",
"priority": 4,
"leagues": [
{
"id": 2599,
"parent": 1000,
"name": "NCAA BASKETBALL",
"sport": {
"id": 24,
"name": "College Basketball"
},
"lineType": "G",
"priority": [
0,
4
],
"part": "0"
},
{
"id": 2631,
"parent": 1000,
"name": "NCAA BASKETBALL ADDED GAMES",
"sport": {
"id": 24,
"name": "College Basketball"
},
"lineType": "G",
"priority": [
1,
4
],
"part": "0"
},
...
在该数组中,您可以看到另一个名为"leagues": [{...}]
的对象,其中包含一个对象,我的过滤器正在通过顶部数组sports
进行搜索,但是一旦我尝试通过{{ 1}}在"name"
数组中,我的应用程序会显示一条消息,指出过滤器为空。
leagues
我一直在尝试所有的方式,使用<input type="search" ng-model="query">
<div ng-repeat="sport in sportsFilter = (sports | filter:query)">
<!--this array works fine-->
<strong>{{sport.name}}</strong>
</div>
<div ng-repeat="league in sport.leagues">
<!--this one not works at all-->
{{league.name}}
</div>
</div>
,使用不同的模型等等,实际上我只是意识到我需要一个自定义过滤器,所以我希望你能帮助我,因为我做了不是从哪里开始的。
还是有更简单的方法吗?