Using controllers

25 views
Skip to first unread message

Олег Истомин

unread,
May 21, 2013, 7:56:49 PM5/21/13
to ang...@googlegroups.com
I can use a controller in two ways.

<blockX ng-controller="Xctrl">
<blockA>business logic</blockA>
<blockB>business logic</blockB>
</blockX>

or
 
<blockX>
<blockA  ng-controller="Actrl">business logic</blockA>
<blockB  ng-controller="Bctrl">business logic</blockB>
</blockX>
 
It does not matter in my simple app. But, when my app will be more difficult some way will be better. What kind of logic I have to guide the creation of controllers? A global controller? Or a separate controller for each scope? Or something in between? I've read the documentation, but there is only technical issues, and examples are too simple and not related to the actual business logic. This is not a technical question, but a question about the architecture of my app.

Dale Botha

unread,
May 22, 2013, 1:12:19 AM5/22/13
to ang...@googlegroups.com
Hi Олег

Because AngularJS is an MVC framework, my answer would be that the controllers use the models.  Are there 2 distinct models for Actrl and Bctrl?
If so and your app will grow in the future than perhaps seperating them out would be the best thing.  As far as a global controller is concerned
I wouldn't know (I'm too inexperienced) but it probably wouldn't hurt to have it.  There doesn't seem to me to be any negatives to it, only a potential benefit in the future!

Ciao

Dale
Reply all
Reply to author
Forward
0 new messages