Reputation: 10611
Hi I'm working on my first AngularJS project. Here is my current route looks like,
$stateProvider
.state('report', {
url: '/report/:Id',
templateUrl: 'templates/report.html'
})
The problem here is /report/:reportId
is handling only the first level, whereas my URL is looking like, /report/:val1/:val2/:val3/:val4/...
and so on. But it is only matching when the URL like /report/:val1
and not anything after.
How to have my URL to match any level? Please help.
Upvotes: 3
Views: 212
Reputation: 10611
I got the answer myself, when I use it with * before the params it is getting values matching up to any level but as a single parameter. Like if you have something like "/report/3/0", controller's $stateParams
have 3/0
. So we can handle further from there.
$stateProvider
.state('report', {
url: '/report/*Id',
templateUrl: 'templates/report.html'
});
angular.module('app.controllers', [])
.controller('reportCtrl', function($scope, $http, $stateParams) {
console.log($stateParams);
});
The above code will print "3/0" in console.
Upvotes: 2