angularjs - Bind function result to angular repeat -


I have an example of a service in my $ scope and its result is through In the Walking Controller

  $ scope.svc = MyService;   

In the template:

   & Lt; Button ng-click = "svc.remove ($ index)" & gt; X & lt; / Button & gt; & Lt; / Td> & Lt; / TR & gt;   

It is easy, thus I can directly point to the methods of service without folded wrap to ng-click . But Does it not reduce the work of angular engine if it is connected to array ? I find time is detected call, each $ scope The change was triggered 2 times it may not be too much but that ng- Repeat Is there any strange damage to this kind of use?

No, there should be no real display effect. Due to data-binding, most resources of repetition are required.

But data binding is also done when you use the array directly, no matter whether it is included directly or returned by the function or not. Only overhead function should be the call and the return of the array, but it is negligible.

However, I would advise the controller to force the service, this is bad behavior. Let's say that you are using the service function multiple times in the template, and then you decide to rename the function - you have to change it even once in the appropriate cover function. At the same time, you have been exposed to automatically template to all service functions, although you may need a subset (ie if you have called in an initialization function that controller if you do not want it most likely That it should be called anywhere in the template.).

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -