After attempting to logout of my current session, I realized that the logout feature is not working. Below is the code I have used:
view
<a ui-sref="logout">
<i class="fa fa-sign-out"></i> Log out
</a>
config.js
$stateProvider
.state('logout', {
url: "/logout",
templateUrl: '',
controller: "LogoutController"
});
controllers.js
function LogoutController($location, $http) {
alert("hi");
//Session.clear();
var request = $http({
method: "post",
url: "users/ajaxLogout",
dataType: 'json',
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
request.success(function(data) {
});
$location.path('/login');
}
angular
.module('inspinia')
.controller('MainCtrl', MainCtrl)
.controller('LogoutController', LogoutController);
Although I have placed an alert in the LogoutController
, it seems that the function is not being triggered when I click the Log out
link.
I referred to this Angular - Logout redirect route for guidance. Kindly review my code and let me know where the error may be occurring.