[英]AngularJS: Login form does not reset on reload
我正在使用angular創建登錄表單。 html如下:
<div class="container" ng-controller="loginCtrl">
<div class="card card-container" >
<img id="profile-img" class="profile-img-card" src="//ssl.gstatic.com/accounts/ui/avatar_2x.png" />
<p id="profile-name" class="profile-name-card"></p>
<form class="form-signin" ng-submit="authenticate()">
<input type="text" id="username" class="form-control" ng-model="username" placeholder="username" required autofocus>
<input type="password" id="password" class="form-control" ng-model="password" placeholder="password" required>
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">Sign in</button>
</form>
</div>
</div>
我的控制器在角度:
ristoreApp.controller("loginCtrl",
['$scope', '$location', 'loginFactory',
function($scope, $location, loginFactory){
$scope.username = '';
$scope.password = '';
$scope.authenticate = function() {
loginFactory.login($scope.username, $scope.password)
.then(function(response) {
loginFactory.setCredentials($scope.username, $scope.password);
$location.path('/home');
}, function errorCallBack(response) {
console.log("Failed auth");
$location.path('/login');
});
}
}]);
該頁面會記住用戶名/密碼,並以表格形式顯示它們,即使我清除了緩存並進行了重新加載。 每次刷新頁面時如何清除表格?
嘗試在密碼字段中為“自動完成”屬性設置“新密碼”:
<input type="password" id="password" autocomplete="new-password" class="form-control" ng-model="password" placeholder="password" required>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.