为什么不NG-应用指令中我的表单提交(angularjs)? [英] Why doesn't my form within the ng-app directive submit (angularjs)?

查看:115
本文介绍了为什么不NG-应用指令中我的表单提交(angularjs)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始接触angularjs,发现一个中的形式NG-应用指令不会提交。我怎样才能使表单提交任何想法?

 <!DOCTYPE HTML>
< HTML NG-应用>
<! - <![ENDIF] - >
< HEAD>
    <间的charset =UTF-8/>
< /头>
<身体GT;
    <形式为GT;
        <输入类型=文本名称=福/>
        <输入类型=提交值=提交/>
    < /表及GT;
    &LT;脚本的src =// ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js\"></script>
    &LT;脚本的src =// ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js\"></script>
&LT; /身体GT;
&LT; / HTML&GT;


解决方案

根据文档


  

角prevents的默认操作(表单提交到服务器),除非&LT;形式&GT; 元素有一个动作属性指定的。


I'm just getting started with angularjs and noticed that forms within a ng-app directive won't submit. Any ideas of how I can make the form submit?

<!DOCTYPE html>
<html ng-app>
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
</head>
<body>
    <form>
        <input type="text" name="foo" />
        <input type="submit" value="Submit" />
    </form>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</body>
</html>

解决方案

According to the documentation :

Angular prevents the default action (form submission to the server) unless the <form> element has an action attribute specified.

这篇关于为什么不NG-应用指令中我的表单提交(angularjs)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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