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 ?