I have made an login page using angularJS, in which I give username and password static, upon submitting the my form it is redirected to a welcome screen, now I want to logout upon clicking logout , to logout from the welcome page and return to login page? how is it possible using angularJS?
here is the code I wrote :
.controller("loginController", function($scope, $location, $rootScope){
$scope.login = function() {
var user = $scope.username;
var password = $scope.password;
var result = $scope.username + $scope.password;
console.log(result);
if (user == "admin" && password == 'admin'){
$rootScope.loggedIn = true;
$location.path('/welcome');
} else {
alert("INVALID CREDENTIALS");
}
}
.controller('welcomeController', function($scope){
$scope.message = "welcome here"
})