當我嘗試使用無效的用戶名和密碼登錄時,它會將消息顯示爲「無效的用戶名或密碼」。當使用錯誤的用戶名或密碼時,如何清除密碼字段 - angularjs
但是,如果它無效的用戶名或密碼,然後密碼字段爲重置。
任何人都可以請幫助我如何做到這一點?
我的控制器:
function login() {
vm.dataLoading = true;
var baseUrl = $location.$$absUrl.split('#')[0];
AuthenticationService.Login(vm.username, vm.password, baseUrl, function (response) {
console.log(response);
if(response.success !== undefined){
FlashService.Error(response.message, true);
} else {
if (response.json.response.statuscode == 0) {
AuthenticationService.SetCredentials(vm.username, vm.password, response.json.response.candidateid, response.json.response.profilestatus);
//(response.json.response.profilestatus < 15) ? $location.path('/otp') : $location.path('/');
$location.path('/')
} else {
FlashService.Error(response.json.response.statusmessage);
vm.dataLoading = false;
}
}
});
};
我的HTML:
<div class=" well tab-content">
<div role="tabpanel" class="tab-pane active" id="personal">
<div class="row">
<div class="col-sm-10 col-lg-offset-1">
<form name="form" ng-submit="vm.login()" role="form">
<div class="form-group" ng-class="{ 'has-error': form.username.$dirty && form.username.$invalid }">
<label for="username">Email</label>
<input type="email" placeholder="Email" name="username" id="username" class="form-control" ng-model="vm.username" required />
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Email required</span>
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Invalid Email Id</span>
</div>
<div class="form-group" ng-class="{ 'has-error': form.password.$dirty && form.password.$error.required }">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="Password" ng-model="vm.password" required />
<span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">Password required</span>
</div>
<div class="form-actions">
<button type="submit" ng-disabled="form.$invalid || vm.dataLoading" class="btn btn-info">Login</button><a href="#/resetpassword" class="btn btn-link">Forgot Password?</a>
<img ng-if="vm.dataLoading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
<hr>
</div>
儘管如此請求尿急,**後,我已經提到過很多次給你**。任何意見? – halfer
你試過下面的答案嗎? – abdoutelb