I have the following data
var data = [
{
"h_id": "31",
"city": "hill",
},
{
"h_id": "13",
"city": "Bevery Hills",
},
{
"h_id": "5",
"city": "New York",
},
{
"h_id": "31",
"city": "New York",
},
{
"h_id": "5",
"city": "New York",
}
];
I am getting data in this format
var data1 = [
{
"h_id": "31",
"city": "hill",
}, {
"h_id": "13",
"city": "Bevery Hills",
}, {
"h_id": "31",
"city": "New York",
}
];
I want data in this format
var data1 = [
{
"h_id": "31",
"city": "hill",
}, {
"h_id": "31",
"city": "Bevery Hills",
}
];
This is my angularjs script
$scope.data1 = $filter('filter')($scope.data , {h_id:31} )
I want the data to be filter based on exact match.filter concept i used above not filtering based on exact match.
h_idof an object you could create ah_idfilter and pass it your Array of objects as the first param and theIDas the second param and then in your$filteruse YOUR_ARRAY.filter(item => item.hi_id === ID PARAM)