T
T
Tash1moto2016-11-07 14:51:00
JavaScript
Tash1moto, 2016-11-07 14:51:00

How to make such a filter in angularjs 1?

Hello.
Simplified the code for clarity.
I get in angular json with a list of products:

[
{
"id": 1,
"name" : "Product1",
"prop1" : "prov1 val",
"prop2" : "prov2 val",
"prop3" : "prov3 val",
},
{
"id": 2,
"name" : "Product2",
"prop1" : "prov1 val",
"prop2" : "prov2 val",
"prop3" : "prov3 val",
},
...
]

there is an object in the $scope of the application:
$scope.props = {
prop1 : ["prov1_val" , "prov1_some_val" , "prov1_etc"],
prop2 : ["prov2_val" , "prov2_some_val" , "prov2_etc"],
prop3 : ["prov3_val" , "prov3_some_val" , "prov3_etc"],
}

arrays in the object ($scope.props) are replenished depending on the selected option, according to the checkbox principle.
Question:
How to filter the list of products, depending on the occurrence of values ​​in $scope.props?
If $scope.props.prop1 is for example an empty array, display all products.
If there are 2 values ​​in $scope.props.prop1, for example, display all products where there is a correspondence between the prop1 of the product and the values ​​in the $scope.props.prop1 array
Please tell me the solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton fon Faust, 2016-11-07
@bubandos

IMHO, you don't need to do this on the frontend - extra traffic, useless load and devouring memory on the client.
Pass the list as a parameter to the server, return suitable products under this set of parameters and you will be happy: fast, beautiful, with pagination.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question