假设我有路线:
app.config(['$routeProvider', function($routeProvider) { $routeProvider.
when('/', {templateUrl: 'partials/myView.html'}).
otherwise( { redirectTo: '/' } );
}]);
我想知道url
到达“otherwise
”时(用户点击的是什么)。例如,将此URL添加到控制台日志中。
有可能吗?
答案 0 :(得分:1)
redirectTo
参数可以是一个函数(source),所以你可以这样做
redirectTo: function(params, currentPath) {
console.log(currentPath);
return '/';
}