2016-02-26 60 views
1

我有一个用户登录和密码的视图。如何记住用户?

<form action="submitLogin()"> 
    <label class="item item-input"> 
    <span class="input-label">Username</span> 
    <input type="text" ng-model="loginData.username"> 
     </label> 
     <label class="item item-input"> 
     <span class="input-label">Password</span> 
     <input type="password" ng-model="loginData.password"> 
     </label> 
     <p style="text-align:center"ng-hide=myflag>wrong credentials</P> 
     <label class="item"> 
     <button class="button button-block button-positive" type="submit">Log in</button> 
    </label> 
    </form> 

我需要的是我需要把一个记住复选框,我需要它的工作控制器。当用户勾选我时。

+3

可能重复问题/ 26645271 /记得我功能和令牌在角jj –

+0

你尝试了什么? – arainone

回答

1

一个简单的解决方案是使用ngStorage。您可以保存用户信息或令牌。 只安装类型:

bower install ngstorage 

npm install ngstorage 

用法:

angular.module('app', ['ngStorage']) 
.controller('Ctrl', function($localStorage){ 
    ... 
}); 

欲了解更多信息,请访问:http://stackoverflow.com/的https://github.com/gsklee/ngStorage