K
K
Konstantin2020-06-15 21:50:08
Angular
Konstantin, 2020-06-15 21:50:08

How to create an Angular data filter?

I have several data models based on which I want to filter an array of objects:

class Status {
    code: string;
}

class Position {
    id: number;
}

class Price {
   discount: bollean;
}


There can be many classes with data models.
How to filter an array of objects by filled models?
There is an approach to use pipe, but I don’t want to put filtering logic for each data model in one pipeFilter - it may differ ... And I also don’t really want to create N number of filterPipe. This looks ugly to use in a template:
filterPipe1 | filterPipe2 | filterPipe3 | filterPipe4 | filterPipe5


Also, the question is whether to separate the filtering logic from the data model?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question