@Pajimola wrote:
Can i ask some help guys thanks
Controllers for login and Home Page
.controller('LoginCtrl', function($scope, $state, $location, LoginService) {
$scope.form = {};
$scope.login = function(){if((angular.isDefined($scope.form.username) && $scope.form.username !== "") && angular.isDefined($scope.form.password) && $scope.form.password !== "") { LoginService.login($scope.form).then(function(response){ if(Storage) { localStorage.setItem('loginDetails', JSON.stringify(response.data.Username)); $state.go('classattendance'); } else { alert('String is not defined in this browser. please use other storage.'); } }, function(error){ }); } else { }
}
$scope.backbutton=function() {
$state.go('home');
}
})
.controller('ClassCtrl', function ($state, $scope,$ionicPopup, $window, $ionicHistory) {
if (localStorage['loginDetails'] == 'undefined')
{
//alert("Invalid access");
$ionicPopup.alert({
title: 'Access Denied',
template: 'Check username and password'
}).then(function(res) {
$window.localStorage.clear();
$state.go('login')
$window.location.reload();
});
};$scope.logout=function() { $window.localStorage.clear(); $ionicHistory.clearCache().then(function(){ $window.location.reload(); $state.go('login') }) }; })
Posts: 1
Participants: 1