【发布时间】:2019-11-22 09:17:30
【问题描述】:
我有一个经典的 html 表单元素,当我将它插入到 Angular 应用程序的 index.html 中时,它可以正常工作。单击按钮提交表单。如果我在 Angular 组件 html 文件中插入相同的表单,它也会被渲染,但是当我单击按钮时,什么也没有发生。
<form method="post" action="https://blub.shtml" id="form" name="form" target="_parent">
<input type="hidden" name="data" value="data" />
<input type="submit" value="Send" />
</form>
为什么会发生这种情况,我该如何解决?
编辑:由于服务器的 CORS 策略,我无法使用 (ngSubmit)。
【问题讨论】:
-
为什么要在 index.html 中放一个表单?
-
我不想把它放在 index.html 中。我想要它在组件中。如果我在 index.html 中测试它,它只是有效。
-
放入组件时出现什么错误?或者只是不会工作
-
没有错误,点击没有任何反应。
-
我认为你应该删除
target="_parent"
标签: javascript node.js angular typescript