Hi I have a URL below:-
http://localhost:8080/test/rpw.html?u=64603549618667520&v=7816fb816d1c6bc85b77b372cc5e5eb9
I want to fetch the value of u & v parameter in the controller, How it can be done please give a detailed description with example
Adding the code snippet
<script>
var app = angular.module('resetPasswd',['ngRoute']);
app.controller('passwordCtrl', [$routeParams, function($scope,$routeParams)
{
var params = $routeParams;
alert("check value "+params.u);
}]);
Inject '$routeParams' into a controller as such and access the $routeParams object and there you have it.
angular.module('app')
.controller('DummyController', ['$routeParams', function($routeParams) {
var params = $routeParams;
}
The above $routeParams gives your controller access to all the parameters in the url in the form of a nice object therefore you are able to access the url parameters very easily. In this case you could do params.u and that would give you your u parameter.
Make sure you injected the ngRoute service into your app beforehand or the above $routeParams won't work.
angular.module('app', ['ngRoute']);
Reference :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.