Angular.js过滤器和范围正在改变每一秒功能 [英] Angular.js filters and functions on scope that is changing every second

查看:126
本文介绍了Angular.js过滤器和范围正在改变每一秒功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的问题。我有条目( $ scope.entries )中,每一行(纳克重复)配有5列,这些列的2已定义了各种变换制成的过滤表。

The problem. I have a table of entries($scope.entries), each row(ng-repeat) with 5 columns, 2 of those columns have custom made filter for various transformations.

现在在同一范围内我有active_entry( $ scope.active_entry ),它正在改变每秒,因为它和工作方式的角度(我猜)中,整个范围正在不断检查,我的过滤器执行。

Now in the same scope I have active_entry($scope.active_entry), which is changing every seconds, because of it and how angular works(I guess), the whole scope is being constantly checked and my filters executed.

这导致的手表防爆pressions 在Batarang去比天高比的时间。

This causes Watch Expressions in Batarang to go sky high over the time.

我如何使用建立某种形式的隔离范围为active_entry所以我的过滤器工作不rended一遍又一遍的每一秒?

How can I use create some sort of isolated scope for the active_entry so my filters are not rended over and over again every second?

时作出指令来创建隔离范围的唯一途径?将它的工作?如果我以后需要值从隔离范围控制器?

Is making a directive the only way to create an isolated scope? Would it work? What if I needed values from the isolated scope later on in the controller?

推荐答案

你问你的问题相当多的问题。这将是更好地问他们每个单独的SO问题。

You are asking quite a few questions in your question. It would be better to ask them each in separate SO questions.

每当一个角消化周期运行,所有的手表和过滤器将运行。改变事物Angualar的内部会造成消化周期运行。你是如何改变 $ scope.active_entry ?如果你能角的外部改变它,你也许可以做你想做的。正如你所说,你也得把该属性到一个新的子作用域(范围:真正的)或隔离范围(范围:{。 ..} ),那么你可以调用 $ scope.digest()(更改后的 active_entry )来只能消化的范围。

Anytime an Angular digest cycle runs, all watches and filters will run. Changing things "inside" of Angualar will cause a digest cycle to run. How are you changing $scope.active_entry? If you can change it outside of Angular, you might be able to do what you want. As you mentioned, you'll also have to put that property into a new child scope (scope: true) or isolate scope (scope: {...}), then you could call $scope.digest() (after you change active_entry) to only digest that scope.

创建指令将创建一个分离范围的最佳途径。您可以创建NG-控制器或指令子作用域。

Creating a directive would be the best way to create an isolate scope. You can create a child scope with ng-controller or a directive.

另请参阅 https://groups.google.com/d/topic/角/ 1XtEAX93ces /讨论

这篇关于Angular.js过滤器和范围正在改变每一秒功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆