Angular js - call a route without view
angularjs, controllers, javascript, route-provider
Solution
You could do :
.when('/auth/logout', {
controller: function(){
//do staff
}
})
btw may be there is something wrong in your code because template works and you could exploit it in the same way
http://docs.angularjs.org/api/ngRoute/provider/$routeProvider
Problem
I'm trying calling the `/auth/logout` url to get redirected after session is deleted: ``` 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('/'); }]); ``` I actually don't need a view for AuthLogout controller but if I do not specify the `templateUrl` in routeProvider I can't get this to work, while if I specify a `templateUrl` it works. How can I call the url/controller without to having to load a view??