I have the following route definition:
..........
when('/:templateFile',
{
templateUrl: function (param) { return 'views/' + param.templateFile + '.html' }
})
..........
The next piece of code listens to the route is changing. If the user is not authenticated and the next page/template to which he wants to navigate is not the login page, then the user is redirected to login page.
Everything works fine except that the next.templateUrl value is actually function (param) { return 'views/' + param.templateFile + '.html' instead of views/login.html, for example.
alert(next.templateUrl) will display function (param) { return 'views/' + param.templateFile + '.html'.
app.run(function ($rootScope, $location) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
if (!$rootScope.IsAuth) {
alert(next.templateUrl); // problem
if (next.templateUrl === "views/login.html") {
} else {
$location.path("/login");
}
}
});
});
Any ideas how I can get the next templateurl when using dynamic templates?