I need one help.I am unable to fetch some value as per some condition using angular.js.I am explaining my code below.
var subcategories = [{
id:1,
name: 'SubCategory 1',
value: 1
}, {
id:2,
name: 'SubCategory 2',
value: 2
}, {
id:3,
name: 'SubCategory 3',
value: 3
}, {
id:4,
name: 'SubCategory 4',
value: 4
}];
var result = $filter('filter')(subcategories, {id:1})[0];
console.log('result',result);
Here i need to fetch all data whose id=1 from subcategories object. But in console i am getting result undefined. Please help me.
subcategories.filter(sub => sub.id === 1)