Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  51] [ 7]  / answers: 1 / hits: 92043  / 10 Years ago, thu, march 27, 2014, 12:00:00

I'm just trying to use $location.path() in my controller but also passing a custom variable as a parameter. So it would look something like this I guess:



$scope.parameter = 'Foo';

$location.path('/myURL/' + $scope.parameter);


But that doesn't work. Anyone know how this is supposed to be done in Angular?


More From » angularjs

 Answers
32

to add Parameters you should use $location.search() method so:



$location.path('/myURL/').search({param: 'value'});


$location methods are chainable.



this produce :



/myURL/?param=value

[#71750] Wednesday, March 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariselas

Total Points: 711
Total Questions: 117
Total Answers: 110

Location: Burkina Faso
Member since Thu, Dec 23, 2021
2 Years ago
;