Hello, i'm looking for best practices on services, controllers and directives for Angularjs 1.3.X.
Here is the rules i noticed :
- The view (html) knows only the main controller and his scope
- A directive should not have his own services
So :
- The view (html) cannot call the services directly.
- The view (html) must use the main controller to access the services.
- The view must declare the binding between the directive and the main controller
And then :
In the code, if a directive have to call a business function F1 of services :
- the main controller must publish a function F2 which wrap the function F1
- the view must declare F2 in the directive configuration
You can look at the picture attached for a more visual explaination.
Questions :
- Are you agree with those rules and the style of code ?
- Do you have any additional rules ?
- Why should we not follow these rules ?
- The view (html) knows only the main controller and his scope
- A directive should not have his own services
So :
- The view (html) cannot call the services directly.
- The view (html) must use the main controller to access the services.
- The view must declare the binding between the directive and the main controller
--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/fIZnAL3sEpo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.