I want to filter nested array using angularjs filter in controller. following is my sample data
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'
}
]
}
];
for example i want to filter the data on title, so if i search "game of thrones" i want to get following data
{
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'
}
]
}
I think similar question has been asked here Angularjs filter nested object
and i tried to use the following code in my controller but it did not worked
var filterdData = $filter('filter')(content, {data: [{title: $scope.filterKey}]});