var weatherApp = angular.module('weatherApp', ['ngRoute', 'ngStorage']);
weatherApp.config(function ($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'html/views/search.html',
controller: 'searchCtrl',
})
.when('/forecast',{
templateUrl: 'html/views/forecast.html',
controller: 'forecastCtrl',
})
.when('/login',{
templateUrl: 'html/views/login.html',
controller: 'loginCtrl',
})
.when('/logout', {
controller: 'logoutCtrl',
})
.otherwise({
redirectTo: '/',
});
});
logout controller
weatherApp.controller('logoutCtrl', ["$scope", "$location", "$localStorage", function($scope, $location, $localStorage){
$localStorage.removeItem("user_email");
$localStorage.removeItem("user_password");
console.log("coming in logout controller!!");
$location.path("/login");
}]);
I have written above code to define routes for my site. For logout, I have defined controller as "logoutCtrl". But My code does not seem to work. When I hit SITE_URL/#/logout, it does not console log neither delete localStorage data.