1

My case, I'm performing ngFor over ES6 collections that get filtered through pipe and converted into array, but when collection contains over 5000 elements ui starts acting sluggy, trivial performance profiling shown that creating large array per every dirty check is overkill, while iteration itself is fast.

So I would like to implement my own ngFor directive that would be capable of iterating through ES6 iterables.

It was simple in Angular 1, but it doesn't seem as easy in Angular 2, where should I start looking to accomplish that?

Lu4
  • 14,873
  • 15
  • 79
  • 132
  • 1
    ngFor already supports iterables. I guess you can start from studying [directive source code](https://github.com/angular/angular/blob/master/modules/%40angular/common/src/directives/ng_for.ts) and core classes that it depends on. The comparison to A1 isn't correct because ng-repeat is hard-coded to arrays and requires full rewrite for iterables. – Estus Flask Aug 29 '16 at 01:22
  • My fault, it really does support iterables, don't understand how I couldn't get it running in my case – Lu4 Aug 29 '16 at 14:02
  • This is answered here - https://stackoverflow.com/questions/46780843/angular-4-filter-search-custom-pipe. See discussion on why pipes for filtering and sorting are anti-patterns and DeborahK's answer on how to handle this properly in Angular 2+. – sfors says reinstate Monica May 25 '18 at 16:58

0 Answers0