I have developed a login page using AngularJS, where I input static username and password. Upon submitting the form, it redirects to a welcome screen. Now, I am looking to implement a logout feature that will transition from the welcome page back to the login page. How can this be achieved with AngularJS?
Below is the code snippet I have written:
.controller("loginController", function($scope, $location, $rootScope){
$scope.login = function() {
var user = $scope.username;
var password = $scope.password;
var result = $scope.username + $scope.password;
if (user == "admin" && password == 'admin'){
$rootScope.loggedIn = true;
$location.path('/welcome');
} else {
alert("INVALID CREDENTIALS");
}
}
.controller('welcomeController', function($scope){
$scope.message = "Welcome here"
})