我有一个与朋友一起构建的应用程序我们有一个非常大的问题:我有一个非常大的json,其中一些嵌套数组是一个对象,我使用的是带有ng-model="search"
过滤器的过滤器(搜索)适用于名为sports
的顶级数组,但是一旦我尝试搜索leagues
数组,过滤器就不会返回任何内容。我在another question看到我可以根据嵌套属性搜索(过滤),这正是我想要的。我试图按照这个问题的示例答案,但我试图解决这个问题。其他人说:这是不可能的,你正在尝试这种匹配,因为你想过滤匹配的sport.name和他所有的匹配和非匹配的联赛或不匹配的sport.name和他的匹配联赛
JSON
[
{
"name": "Cricket",
"leagues": []
},
{
"name": "NBA Games",
"leagues": [
{
"name": "NBA",
"sport": {
"id": 8,
"name": "NBA Earliest"
},
"lineType": "G",
"priority": [
1,
3
],
"part": "0"
}
]
},
{
"name": "COLLEGE Basketball",
"leagues": [
{
"name": "College - NCAA BASKETBALL",
"sport": {
"id": 24,
"name": "College Basketball"
},
"lineType": "G",
"priority": [
0,
4
],
"part": "0"
},
{
"name": "NCAA BASKETBALL ADDED GAMES",
"sport": {
"id": 24,
"name": "College Basketball"
},
"lineType": "G",
"priority": [
1,
4
],
"part": "0"
},
...
我的HTML
<input type="search" ng-model="search">
<div ng-repeat="sport in sports | filter: query">
<!-- searching (filtering) great -->
<div>{{sport.name}}</div>
</div>
<div ng-repeat="league in sport.leagues | filter: query">
<!-- here is not filtering at all -->
{{league.name}}
</div>
</div>
我可以这样做,我正在尝试或如何为此实现自定义过滤器?