2016-05-04 21 views
0

Ich benutze Angular, um ein Login-Formular zu erstellen. Die HTML ist wie folgt:AngularJS: Anmeldeformular wird beim Reload nicht zurückgesetzt

<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> 

Mein Controller in Winkel:

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'); 
      }); 
     } 
    }]); 

Die Seite erinnert sich der Benutzername/Passwort und zeigt sie in Form, auch wenn ich klar Cache und hart reload. Wie lösche ich das Formular jedes Mal, wenn ich die Seite aktualisiere?

+0

Könnten Sie zeigen uns Ihre loginCtrl Code? –

+0

@FelippeDuarte Controller hinzugefügt. – ddd

+0

Ich hatte einen ähnlichen Fehler in Chrom. Haben Sie versucht, das Attribut autocomplete = "off" hinzuzufügen – yBrodsky

Antwort

2

Try 'new-password' für die 'Autocomplete' Attribut in Ihrem Passwortfeld:

<input type="password" id="password" autocomplete="new-password" class="form-control" ng-model="password" placeholder="password" required> 
Verwandte Themen