Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I read in some questions here, that you shouldn't change the data inside the filter. Now my problem is that the API I am using doesn't support a query to filter the data from the server. My only option is to load everthing and filter it inside my App.

My approach was to write a custom filter, which filters the already downloaded data and then downloads the next 100 entries (another limitation of the API). This will be repeated until everything is downloaded.

Example Data

    "name": entry.name,
    "thumb": entry.thumbnail,
    "date": entry.date,
    "hide": false

Example Code (I know the filter wouldn't work that way, but since I think the entire approach is wrong, it doesn't matter for now)

customMod.filter('CustomFilter', function(entry){
       entry.hide = (entry.name.indexOf("bla") === -1);
       loadNewDataAndAddToEntries();
})

View

<div data-ng-repeat="entry in entries | CustomFilter" data-ng-class="{true:'hide'}[entry.hide]">...</div>

What would be a better or the correct approach to do this?

share|improve this question

closed as primarily opinion-based by Stewie, Qantas 94 Heavy, Mike W, Travis J, Benjamin Gruenbaum Dec 22 '13 at 2:23

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.