0

Im using nodejs memoize to chunk an object in Angularjs (to better use it with bootstrap columns)

app.filter('chunk', function() {
   return memoize(chunk);
});

and in view:

<div class="row" ng-repeat="row in groupProjects | chunk:4">
   <div class="col-xs-12 col-sm-6 col-md-3" ng-repeat="item in row">
      {{item.name}}
   </div>
</div>

But if i get new data for groupProjects in my controller, thew view is not updated. It updates, if i remove the filter, but not with it.

What causes the problem? Thanks

2 Answers 2

0

Not sure what the value of chunk is, but assuming it's a function then your code should look like this:

app.filter('chunk', memoize(chunk));
0

I don't get why NodeJS should be involved in this but anyway, you can do this by injecting underscore (or lodash) in your app. Notice, we memoize this function to prevent Angular starting infinite amount of digests.

app.factory "lodash", ["$window", ($window)->
  $window._
]

#filters
app.filter "chunk", ["lodash", (_)->
  _.memoize _.chunk
]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.