How to pass multiple parameter?

Here is an example code ( more code attached) from Angular JS Routing Controller I’m studying .
Need some help on this.

var myApp = angular.module('myApp', ['ngRoute']);

myApp.config(function ($routeProvider) {
    
    $routeProvider
    
    .when('/', {
        templateUrl: 'pages/main.html',
        controller: 'mainController'
    })
    
    .when('/second', {
        templateUrl: 'pages/second.html',
        controller: 'secondController'
    })
    
    .when('/second/:num', {
        templateUrl: 'pages/second.html',
        controller: 'secondController'
    })
    
});

myApp.controller('mainController', ['$scope', '$log', function($scope, $log) {
    
    $scope.name = 'Main';
    
}]);

myApp.controller('secondController', ['$scope', '$log', '$routeParams', function($scope, $log, $routeParams) {
    
    $scope.num = $routeParams.num || 1;
    
}]);

when url is /second/3 we get value 3 from code snippet $routeParams.num.

Queries
Do we need to send data in tree structure ? like this /second/3 …Does it not support query string as we normally do in web application ?

In this example , we had only 1 param to send i.e 3 … suppose If we wanted to send multiple parameters and want to get those multiple values , how could I do that ?

Code-Routing-Templates-Controllers-Part-2.zip (1.8 KB)

So i don’t think angular supports query strings out of the box. And you should be able to add as many url parameters as required. They will need to be "second/:num/:nextparam/:nextparam" etc…

Thanks…that was very much helpful

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.