There are a few options 1 If you want the state to be stored to history, or there on refresh, then use a url variable.
2 If your state is specific to a purpose, then storing the value on a service is often the best way. Your other controller can share a reference to the service. 3. If you are just looking for simple communication, then maybe look at events. You can use $rootScope.$emit and $rootScope.$on 4 Also, We have a service which is an 'eventChannel', which is basically an instance of an EventEmitter (look at nodejs). This means that you can dispatch events to other parts of your application and listen globally. I find this neater than using $rootScope.xxx for events On 17 November 2014 15:24, Hastek <[email protected]> wrote: > I am an angular newbie. I am trying to pass a selected value from one view > to the other while navigating using $location.path . I see two options; > 1) pass it as part of the url : $location.path('/location/' + > modes.searchType) > 2) use a common service between the two controllers and save/retrieve the > selected parameter using a service property/variable. > > please help me suggesting which is the right/best practice. One thing I am > assuming is the url option could be useful incase of caching.. > > -- > 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/d/optout. > -- Tony Polinelli -- 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/d/optout.
