angularjs - Call Service function and change the view -


i new javascript , angular.js. working on app show direction between address using google api.i have question related calling function , change view. in view-controller, searchaccount/searchaccount.js allow user select account.. in different location view , show direction between selected. pass data between view , using service...i call service function , use $lcoation change view. however, in service function , not able element of location.my service functon runs before location view loaded.

$scope.showmaps = function(){                $location.path('/locations');                //getdirections.showdirections($scope.accountchecklist);                getdirections.maponpage($scope.accountchecklist);           } 

in maponpage , not able pick elements of location.html.. best practices around this. thanks