从设置形式为$脏angularjs prevent输入 [英] Prevent input from setting form $dirty angularjs

查看:83
本文介绍了从设置形式为$脏angularjs prevent输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面上的NG形式。在窗体中我有需要显示一个保存对话框当表单脏了几个控件,即形式。$脏= TRUE。然而,有形式,我不想弄脏等形式的导航控件。假设我不能动控制表单的。

I have an ng form on a page. Inside the form I have several controls which need to display a save dialog when the form is dirty, ie form.$dirty = true. However there are some navigation controls in the form I don't want to dirty the form. Assume I can't move the control out of the form.

请参阅: http://plnkr.co/edit/bfig4B

我如何做选择框不脏的形式?

How do I make the select box not dirty the form?

推荐答案

角只设置肮脏的形式,如果控制是质朴的。因此,这里的关键是要设置$上的控制,以虚假的质朴。你可以这样做在控制器​​超时。

Angular only sets the form dirty if the control is pristine. So the trick here is to set $pristine on the control to false. You can do it in a timeout in the controller.

请参阅: http://plnkr.co/edit/by3qTM

这篇关于从设置形式为$脏angularjs prevent输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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