3

我对 AngularJS 比较陌生,我正在尝试总结一个常规形式。我的基本形式如下所示:

<form method="post" enctype="multipart/form-data">
input type="text" class="title span5" name="post_title" placeholder="A catchy title here..." value="" />

<input type="file" name="post_image" />

<input type="submit" class="btn btn-success" value="Create Post" />
</form>

但我注意到 AngularJS 将自己的值添加到表单中。

<form method="post" enctpye="multipart/form-data" class="ng-pristine ng-valid">

我无法提交表格。如何禁用 Angular JS 添加到应用程序的自动验证?

4

2 回答 2

5

文档中引用:

出于这个原因,Angular 会阻止默认操作(向服务器提交表单),除非元素具有指定的操作属性。

恕我直言,您应该阅读文档以获得对单页应用程序的一般理解,以及 Angular 阻止默认行为的原因。

于 2013-06-17T19:39:14.613 回答
-1

UPDATE : This does NOT work ... well at least not in a way you'd like it to. Adding ng-non-bindable to the form or any input breaks ALL binding. So, your ng-model in the inputs won't work anymore.


ng-non-bindable is possibly your best choice. It will prevent AngularJS from doing ANY validation. So, you'll be responsible for showing invalid and checking validity.

https://stackoverflow.com/a/19387233/75644

于 2013-10-15T17:30:44.240 回答