Angular filter works but causes “10 $digest iterations reached”

前端 未结 7 1434
走了就别回头了
走了就别回头了 2020-11-30 00:56

I receive data from my back end server structured like this:

{
  name : \"Mc Feast\",
  owner :  \"Mc Donalds\"
}, 
{
  name : \"Royale with cheese\",
  owne         


        
7条回答
  •  生来不讨喜
    2020-11-30 01:56

    Thanks for the memoize solution, it works fine.

    However, _.memoize uses the first passed parameter as the default key for its cache. This could not be handy, especially if the first parameter will always be the same reference. Hopefully, this behavior is configurable via the resolver parameter.

    In the example below, the first parameter will always be the same array, and the second one a string representing on which field it should be grouped by:

    return _.memoize(function(collection, field) {
        return _.groupBy(collection, field);
    }, function resolver(collection, field) {
        return collection.length + field;
    });
    

提交回复
热议问题