angular grouping filter

后端 未结 3 1196
独厮守ぢ
独厮守ぢ 2021-01-02 01:35

Following angular.js conditional markup in ng-repeat, I tried to author a custom filter that does grouping. I hit problems regarding object identity and the model being watc

3条回答
  •  醉酒成梦
    2021-01-02 01:48

    Regardless, I'm still seeing the $digest error, which is puzzling: plnkr.co/edit/tHm8uYfjn8EJk3cG31DP – blesh Jan 22 at 17:21

    Here is the plunker forked with the fix to the $digest error, using underscore's memoize function: http://underscorejs.org/#memoize.

    The issue was that Angular tries to process the filtered collection as a different collection during each iteration. To make sure the return of the filter always returns the same objects, use memoize.

    http://en.wikipedia.org/wiki/Memoization

    Another example of grouping with underscore: Angular filter works but causes "10 $digest iterations reached"

提交回复
热议问题