Best practice for Utility functions

5,509 views
Skip to first unread message

ami...@gmail.com

unread,
Aug 31, 2012, 12:49:08 PM8/31/12
to ang...@googlegroups.com
All,

What's the best or recommended pattern for a app-wide utility class? We're currently "porting" an app to Angular and we have an Util js class that has common functions that are used throughout the lifetime of the app. So, what's the equivalent of an app-global library in Angular, and more importantly, how can we inject it as a dependency inside controllers? TIA 

Pawel Kozlowski

unread,
Aug 31, 2012, 1:02:32 PM8/31/12
to ang...@googlegroups.com
Hi!
You might find this response on SO useful:
http://stackoverflow.com/questions/11938380/how-to-go-globals/11938785#11938785
Basically your best option would be to create a service, especially if
you are after injecting those utilities into controllers.

Hope this helps,
Pawel

Ruben D. Orduz

unread,
Aug 31, 2012, 1:40:41 PM8/31/12
to ang...@googlegroups.com
Just what I thought! Thanks! :)
> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to angular+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en.
>
>
Reply all
Reply to author
Forward
0 new messages