How do I access the url in the setTitle anonymous function?
I have something like below in my route setup for Angular. Most routes point to the same controller, there are some differences in the controller but essentially the problem is duplicated routes. So I want to move to something that only has one entry in the table, but need to change the SetWindowTitle to set the title based on the url paramter. The code I have displayed does not work as the producttype var is undefined.
Current code:
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/mypage/round', {
templateUrl: 'product',
controller: 'productController',
resolve: {
setTitle: function() {
SetWindowTitle('product round')
}
},
})
.when('/mypage/square', {
templateUrl: 'product',
controller: 'productController',
resolve: {
setTitle: function() {
SetWindowTitle('product square')
}
},
})
// etc...
Want something like:
$routeProvider
.when('/mypage/:producttype', {
templateUrl: 'product',
controller: 'productController',
resolve: {
setTitle: function() {
SetWindowTitle('product ' + producttype)
}
},
})