Last active
August 29, 2015 14:06
-
-
Save jsdevel/03f28b38ed0c06860cfc to your computer and use it in GitHub Desktop.
angular sign in form getting cleared
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SignInCtrl( | |
$rootScope, | |
$scope, | |
credentials, | |
events, | |
handleUser, | |
User | |
){ | |
$scope.isLoading = false; | |
$scope.generalError = ''; | |
$scope.hasBeenSubmitted = false; | |
$scope.submit=function(){ | |
var password = $scope.signin.password.$modelValue; | |
var username = $scope.signin.username.$modelValue; | |
var rememberMe = $scope.signin.rememberMe.$modelValue; | |
var query = { | |
userId: username | |
}; | |
if(rememberMe)query.rememberMe = rememberMe; | |
//reset | |
$scope.generalError=''; | |
$scope.hasBeenSubmitted=true; | |
if($scope.signin.$invalid || $scope.isLoading){ | |
~ return false; | |
} | |
credentials.set(username, password); | |
User.get( | |
query, | |
function(user){ | |
$scope.isLoading = false; | |
$scope.generalError=''; | |
$scope.hasBeenSubmitted=false; | |
//success | |
}, | |
function(response){ | |
$scope.generalError = response.data; | |
$scope.isLoading = false; | |
//failure | |
} | |
); | |
$scope.isLoading = true; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form( | |
ng-controller="SignInCtrl", | |
ng-submit="submit()", | |
ng-cloak, | |
name="signin", | |
ng-class="{\ | |
'is-submitted-true': isLoading,\ | |
'is-submitted-false': isLoading\ | |
}", | |
ng-if="!state.registering", | |
class="sign-in", | |
novalidate | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment