我试图调用/auth/logout
URL会被删除后重定向:角JS - 呼叫路由,而不视图
app.config(['$routeProvider',function($routeProvider) {
$routeProvider
.when('/auth/logout',{
controller:'AuthLogout'
//templateUrl: not needed
})
})
.controller('AuthLogout', ['$window','$location', function ($window,$location) {
$window.localStorage.removeItem('user_username');
$window.localStorage.removeItem('user_id');
$window.localStorage.removeItem('user_session_token');
$location.path('/');
}]);
我其实并不需要AuthLogout控制器的视图,但如果我不这么做在routeProvider中指定templateUrl
我无法得到此工作,而如果我指定templateUrl
它的作品。
如何在不需要加载视图的情况下调用url/controller?
尝试模板警报:“”有点棘手,但它应该工作^^ – Whisher
我得到一个无限循环和浏览器崩溃与此:O – sbaaaang
这是奇怪的,当你可以使用块或模板或templateUrl,所以无限循环,我认为它不相关。 – Whisher