Angular Route Parameters

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;
});

About Blogger

ANIL SINGH

Hey! I am Anil Singh. I am Active Blogger, Writer and Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book