A
A
Alexey Romanov2015-02-10 12:27:45
JavaScript
Alexey Romanov, 2015-02-10 12:27:45

How to implement AngularJS filtering on an array for a single parameter?

Everyone will accept, I just started to get acquainted with AngularJS, if anything, do not scold =)
The essence of the question is to organize filtering of documents by an array with categories.
There is an array with documents, each document has its own categories.

[{"id":"1","name":"test 1","categories":[139,174]},
{"id":"2","name":"test 2","categories":[132,174]},
{"id":"3","name":"test 3","categories":[149,174]},
{"id":"4","name":"test 4","categories":[139,171]},
{"id":"5","name":"test 5","categories":[94,174]}]

You need to filter by an array of categories.
an example of an array of categories,
{"0":{"id":139},{"id":132}, "1":{"id":149}}
As a result, to display documents only
  • test 1
  • test 2
  • test 3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DigitalSmile, 2015-02-10
@DigitalSmile

Use the ngRepeat directive with the filter https://docs.angularjs.org/api/ng/directive/ngRepeat (there is an example with a filter at the end).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question