AngularJS $ routeParam vs $ location.search (a, b) difference?
Setting the URL parameter via $ routeParams or setting it using $ location.search () as a setter seems to do the same thing, except for how the parameter appears in the URL and where in the app it is set.
From app.js config ...
$routeProvider
.when('/myRoute/:myParam', {});
against.
From the controller ...
$scope.setLocationParam = function (name, param) {
$location.search(name, param);
};
I have a simple ajax application where I am going step by step through multiple pages and I want to maintain state in the url so that each subsequent route calls the api based on the url parameters set from the previous route.
When do you want to choose one method over the other?
I'm leaning towards the $ location search parameter because it's more descriptive, but I thought I'd ask you good people! s
+3
source to share
No one has answered this question yet
Check out similar questions: