【发布时间】:2016-01-29 03:02:08
【问题描述】:
如果使用 ng-include 将表单帖子包含在父 html 中,则不会触发表单帖子。
<div ng-include src="'form.html'"></div>
form.html文件代码如下
<form action="next/login" method ="post">
<table>
<tr>
<td class="login_input_field v_align_top">
<input type="text" name="email" ng-model="email">
</td>
<td class="login_input_field">
<input type="password" name="pass" ng-model="password">
</td>
<td class="login_button_container">
<button type="submit" id="login" name="login">Login</button>
</td>
</tr>
</table>
</form>
如果我以表单形式提交,则 URL 不会在浏览器的 URL 栏上导航。没有对提交事件执行任何操作。
请解释功能背后的角度逻辑。
这与包含模板无关。
问题:
表单提交行为改变 示例 html 页面:index.html 1)我在 index.html 页面中有一个表单,提交它会改变我的 URL,然后页面刷新并获得响应 2) 如果我在模板中有表单并将其包含在 index.html 中。 URL 不会改变,页面也不会刷新。
第 1 点和第 2 点有什么区别?
【问题讨论】:
-
为什么是“'form.html'”?它不应该是:“form.html”吗?注意你的 ' (单引号)。
-
"form.html" 将行为具有范围变量。当您与“'form.html'”绑定时,它将充当字符串并搜索匹配的模板名称
-
你可能应该选择
标签: javascript jquery html angularjs forms