Create a helper/utility class in angularjs

1,660 views
Skip to first unread message

Angular goodPractices

unread,
Nov 13, 2015, 11:09:15 AM11/13/15
to AngularJS
Hi,

We have recently re-written UI for our project in AngularJS. I want to understand the angular guidelines and the best practices to develop. 

Basically, I want to move some functions from controller class to a helper class. Can I simply create a utils class and call those functions in controller?

Vaibhav Gupta

unread,
Nov 16, 2015, 7:28:15 AM11/16/15
to AngularJS
Hi,

We have recently re-written UI for our project in AngularJS. I want to understand the angular guidelines and the best practices to develop. 

You may refer to the following styleguide:

Basically, I want to move some functions from controller class to a helper class. Can I simply create a utils class and call those functions in controller?

Can you be more specific in this? You can create utils service/factory. Controllers should be thin, adhering to MVC pattern.  

András Csányi

unread,
Nov 16, 2015, 8:57:03 AM11/16/15
to ang...@googlegroups.com
Hi,

I would implement those helpers as services and inject them into controllers, other services if it is needed.
 
Reply all
Reply to author
Forward
0 new messages