The Angular Route Parameters :-
In the above example, we have
declared three links with routes parameters with are given below.
"#/ruteoURL1/1001" "#/ruteoURL2/1002" "#/ruteoURL3/1003"In the above URLs, 1001, 1002 and 1003 are route parameters which are specified in the URLs and these parameters are added in the $routeProvider routes path i.e.
$routeProvider.when('/routeURL1/:params', { templateUrl: 'templateURL1', controller: 'routesController' }). when('/routeURL2/:params>', { templateUrl: 'templateURL2', controller: 'routesController' }). when('/routeURL3/:params', { templateUrl: 'templateURL3', controller: 'routesController' }). otherwise({ redirectTo: '/login' });
Now in the above
routes, the when () function contain the parameters (:
params) and the: params value will get from the $routeParams controller
parameters. You can see the below code sample.
app.controller("routesController", function ($scope, $routeParams) { $scope.params = $routeParams.param; });
Blogger Comment
Facebook Comment