Accessing services in the view

1,477 views
Skip to first unread message

Adam Wynne

unread,
Apr 9, 2012, 7:08:08 AM4/9/12
to ang...@googlegroups.com
Hi guys

I'd like to be able to access my services in the view (so if I've written a service called 'auth', I could use something like ng-show="auth.loggedIn"

this (broken) fiddle demonstrates what I'd like to do:

Any help appreciated

Thanks
Adam

Peter Bacon Darwin

unread,
Apr 9, 2012, 10:57:46 AM4/9/12
to ang...@googlegroups.com
In this fiddle the $location service is passed straight through to the scope.  Personally, I would use the controller to give a layer of abstraction between the view and the service by creating a method like your url() method.
Pete

Adam

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/_5z5drd-NukJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Adam Wynne

unread,
Apr 9, 2012, 3:57:37 PM4/9/12
to ang...@googlegroups.com
brilliant - thanks :)


On Monday, April 9, 2012 3:57:46 PM UTC+1, Peter Bacon Darwin wrote:
In this fiddle the $location service is passed straight through to the scope.  Personally, I would use the controller to give a layer of abstraction between the view and the service by creating a method like your url() method.
Pete

On 9 April 2012 12:08, Adam Wynne <adam...@gmail.com> wrote:
Hi guys

I'd like to be able to access my services in the view (so if I've written a service called 'auth', I could use something like ng-show="auth.loggedIn"

this (broken) fiddle demonstrates what I'd like to do:

Any help appreciated

Thanks
Adam

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/_5z5drd-NukJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages