I am trying to find the projects by its project ids. For that, I am using this filter method:
$scope.filteredPro = $filter('filter')( project.ProjectSummaryFilter, {"ProjectId" : "1" } );
But when I am getting the result, the project which has the id as 1
and 10
appears as well.. in this case if I make my filter using only by 10
like this:
$scope.filteredPro = $filter('filter')( project.ProjectSummaryFilter, {"ProjectId" : "10" } );
I am exactly getting the result from the id of 10
. How can fix this?
Why am I getting a result including the project which has the id of 10
as well when I filter by 1
?
for an exact match, you should try:
$scope.filteredPro = $filter('filter')( project.ProjectSummaryFilter, {"ProjectId" : "1" },true );
$filter('filter')(array, expression, comparator)
where expression:
Object: A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of items which have property name containing "M" and property phone containing "1"
where comparator value:
true: A shorthand for function(actual, expected) { return angular.equals(actual, expected)}. This is essentially strict comparison of expected and actual.