I have a dynamic value params in url and I want to get it and use in controller when onload
But I have no idea how to deal with $route.current.params
Let say I have this route provider
$routeProvider.when('foo/:bar', {templateUrl: 'template.html'};
Then in my controller
app.controller('mapCtrl', function($scope, $route, $routeParams) {
var param = $route.current.params.bar;
console.log(param);
});
If user access foo/abcdefg
suppose should show abcdefg in console but I got error.
'Cannot read property 'params' of undefined'
$routeProvider.when('foo/:bar', {templateUrl: 'template.html', controller: 'mapCtrl'};
app.controller('mapCtrl', function($scope, $route, $routeParams) {
var param = $routeParams.bar
console.log(param);
});