Soh*_*qui 1 javascript filter angularjs
我想在控制器中使用angularjs过滤器过滤嵌套数组。以下是我的示例数据
dummy=[
{
category:'TV',
data:[
{
title: 'Game of Thrones',
path: 'some data1',
},
{
title: 'Game of Thrones-SD',
path: 'some data2'
},
{
title: 'Game of Thrones-HD',
path: 'some data3'
},
{
title: 'Game of Thrones-Trailer 1',
path: "some data4"
},
{
title: 'Game of Thrones-Trailer 2',
path: "some data5"
},
{
title: 'Game of Thrones-Trailer 3',
path: "Ssome data6"
},
{
title: 'The Vampire Diaries ',
path: 'some data7'
},
{
title: 'The Vampire Diaries -SD',
path: 'some data8'
},
{
title: 'The Vampire Diaries -HD',
path: 'some data9'
},
{
title: 'The Vampire Diaries -Trailer 1',
path: 'some data10'
}
]
},
{
category:'LIVE',
data:[
{
title: 'Game of Thrones - Live Show',
path: 'some data11'
},
{
title: 'The Vampire Diaries - Live Show',
path: 'some data11'
}
]
}
];
Run Code Online (Sandbox Code Playgroud)
例如,我想过滤标题数据,所以如果我搜索“权力游戏”,我想获取以下数据
{
category:'TV',
data:[
{
title: 'Game of Thrones',
path: 'some data1',
},
{
title: 'Game of Thrones-SD',
path: 'some data2'
},
{
title: 'Game of Thrones-HD',
path: 'some data3'
},
{
title: 'Game of Thrones-Trailer 1',
path: "some data4"
},
{
title: 'Game of Thrones-Trailer 2',
path: "some data5"
},
{
title: 'Game of Thrones-Trailer 3',
path: "Ssome data6"
},
]
},
{
category:'LIVE',
data:[
{
title: 'Game of Thrones - Live Show',
path: 'some data11'
}
]
}
Run Code Online (Sandbox Code Playgroud)
我认为这里有人问过类似的问题 Angularjs过滤嵌套对象
我试图在控制器中使用以下代码,但没有成功
var filterdData = $filter('filter')(content, {data: [{title: $scope.filterKey}]});
Run Code Online (Sandbox Code Playgroud)
小智 5
这对我有用
var filterdData = $filter('filter')(content, {data: {title: $scope.filterKey}});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8027 次 |
| 最近记录: |