简体   繁体   English

如何使用angularjs验证动态创建的表单?

[英]How to validate the dynamically created form using angularjs?

Actually I'm creating the form dynamically and i have done two way binding also. 实际上,我是动态创建表单的,并且我也完成了两种方式的绑定。 Now I want to do the validation. 现在我要进行验证。

Requirements: 要求:

    1. If i have value in field for (eg. Name: Raja) . 如果我在字段中具有值(例如名称:Raja) If edit that value using $watch or $dirty we can check that modified or not. 如果使用$watch$dirty编辑该值,我们可以检查是否已修改。 The same thing I want to get reverse also. 同样的事情我也想扭转。 Suppose I edited the value Raja to Raj and later again i'm adding the 'a' means Raja. 假设我将Raja的值编辑为Raj,稍后再添加“ a”表示Raja。 If i give previous value again the status $dirty i should get false. 如果我再次赋予先前的值$dirty状态,我应该为假。
    1. How can do this thing for whole form rather than giving each and every field. 如何从整体上而不是每个领域都做这个事情。

Please help me anyone on this. 请帮助我任何人。

Here is my Plunker for simple example. 这是的简单例子。

您应该使用类似$setPristine()东西http://plnkr.co/edit/1LJ5alREMhFXOqO8ZWbj?p=preview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM