Dear, I went through a question where the accepted answers suggested using a filter with ng-repeat, which mainly uses the lodash chunk function along with the memoize function. The author describes the reason for using memoize after
Many people prefer to do this in a view using a filter. It is possible, but it should be used only for display! If you add input to this filtered view, it will cause problems that can be resolved, but are not pretty or reliable.
The problem with this filter is that it returns new nested arrays every time. Angular monitors the return value from the filter.The first time the filter runs, Angular knows the value, then starts it again to make sure that it is done. If both values are the same, the cycle has ended.If not, the filter will fire again and again until they become the same, or Angular is implemented, and an infinite digest cycle happens and goes off.Since the new nested arrays / objects were not previously tracked by Angular, it always sees a return value that is different from the previous one.To fix these “erratic” filters, you must wrap the filter in a function memoize.lodashhas a function memoize, and the latest version lodashalso includes a function chunk, so we can create this filter very simply using modules npmand compile a script with browserifyor webpack.
The problem with this filter is that it returns new nested arrays every time. Angular monitors the return value from the filter.
The first time the filter runs, Angular knows the value, then starts it again to make sure that it is done. If both values are the same, the cycle has ended.
If not, the filter will fire again and again until they become the same, or Angular is implemented, and an infinite digest cycle happens and goes off.
Since the new nested arrays / objects were not previously tracked by Angular, it always sees a return value that is different from the previous one.
To fix these “erratic” filters, you must wrap the filter in a function memoize.
memoize
lodashhas a function memoize, and the latest version lodashalso includes a function chunk, so we can create this filter very simply using modules npmand compile a script with browserifyor webpack.
lodash
chunk
npm
browserify
webpack
- , memoize ng-repeat ?
, .filter('chunk', func) angular, :
< > " , " chunk", , , :
param1: the array on which it was applied. param2: the part after ':'
"
, , .
, , , . , , , chunk e.t.c...
memoize, : " ( ), ".
, :
Source: https://habr.com/ru/post/1606233/More articles:Check chrome.storage.sync while debugging the Chrome extension. - javascriptExpress check Paypal vs REST api? - paypalBigQuery can't create view, but query is ok - google-bigqueryIOS 8 sprite set collides with top and bottom, but not with sides? - iosSQL Server различная производительность запросов - sql-serverIs there a more efficient way to do things according to which checkboxes are checked? - performanceFind max (and min) on a move interval with python - pythonAsynchronous method call in Razor mode - asp.net-mvciland.hbm.Atom _ $$ _ javassist_21 не может быть передан в javassist.util.proxy.Proxy exception - javaR conditional grouping of lines and numbering of groups - rAll Articles