使用 AngularJS 和 ng-submit 记住密码 [英] Remember Password with AngularJS and ng-submit

查看:17
本文介绍了使用 AngularJS 和 ng-submit 记住密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 AngularJS 单页应用程序中使用 ng-submit 时,如何让浏览器要求用户记住密码.

How do I get the browser to ask the user to remember the password when using ng-submit in an AngularJS single page application.

我的表格:

<form action="/#/dashboard/login" onsubmit="return false;" ng-submit="login()" name="loginForm">
    <input type="text" required id="username" name="username" ng-model="username" autocomplete="on" placeholder="Username" value="">
    <input type="password" required id="password" name="password" ng-model="password" autocomplete="on" placeholder="Password" value="">
    <button type="submit" class="btn">Submit</button>
</form>

有什么想法吗?

我刚刚添加了让浏览器识别表单并欺骗它记住密码的操作.(这显然不起作用.)没有动作,表单可以正常工作.onsubmit="return false;" 阻止操作的执行.只有 ng-submit 在做任何事情.

I just added the action to get the browser to recognise the form and trick it into remembering the password. (which obviously didn't work.) The form works fine without the action. The onsubmit="return false;" prevents the execution of the action. Only the ng-submit is doing anything.

推荐答案

问题在于动态生成的登录表单.将表单放入 index.html 后,它按预期工作.我想这是一个安全问题.

The problem is the dynamically generated login form. After putting the form into the index.html it worked as expected. I guess this is a security issue.

然后发生的问题是 ngModels 没有在自动填充时更新.经过一番搜索,我在此处找到了该问题的解决方案.在 AngularJS 1.2+ 中,这应该是固定的.

The problem that then occurred was that the ngModels didn't get updated on autofill. After some searching I found the solution to that problem here. In AngularJS 1.2+ this is supposed to be fixed.

这篇关于使用 AngularJS 和 ng-submit 记住密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆