Considering the following 2 approaches:

#1 => controllerOne is injected once

<div ng-controller="controllerOne">

 ...

{{ fromControllerOne }}

{{ fromControllerOne }}

 ...


<div ng-controller="controllerTwo">

{{ fromControllerTwo }}

</div> 


<div>

{{ fromControllerOne }}

</div> 

 

<!-- more divs -->

 ... 

</div> 



#2 => controllerOne is injected twice strictly when it is needed

<div>

 ...

<span ng-controller="controllerOne">

{{ fromControllerOne }}

{{ fromControllerOne }}

</span> 

 ...


<div ng-controller="controllerTwo">

{{ fromControllerTwo }}

</div> 


<div ng-controller="controllerOne">

{{ fromControllerOne }}

</div> 

 

<!-- more divs -->

 ... 

</div>  



Questions:

   - Which one is better approach? Why?
   - Is there any performance hit if the controller is declared multiple 
   times in a view? 

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to