Not sure exactly what you are trying to do, but agree with Witold that services are injected into controllers and then they can handle using $location.
Another option, not that it's a good one, but just to pose it for thought is that you can inject $rootScope into the service and $broadcast an event that will trigger down into any active controller. I do something like this to keep my service from making an action itself, but define a common event that could happen anywhere and manage it from one place (like the .run() section or my main controller that doesn't get lost on routes). On Monday, March 3, 2014 4:01:17 PM UTC-7, Witold Szczerba wrote: > > You just named it. Call services from controllers, make your services > return promises (e.g. returning $http.get... or $http.get...then... or your > own promises) and act upon results in controllers, using $location or > what-else responsible for navigation. > > Regards, > Witold Szczerba > --- > Sent from my mobile phone. > On Mar 3, 2014 7:11 PM, "Louis-Philippe Laurin" > <[email protected]<javascript:>> > wrote: > >> Hi, >> >> I am new to AngularJS and wondering what is the best pattern for >> conditional navigation based on a service call result. >> >> When receiving a web request response at my service level. What is the >> best pattern to navigate to the right page in my app? The location and >> navigation services can be accessed from anywhere due to Angular but I >> would like to keep my separation of concerns and leave the navigation into >> the controller and my business logic in my service. Is there a right way to >> do it? >> >> Thanks in advance, >> LP >> >> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/groups/opt_out. >> > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
