angular - 在 Angular 2 模板中使用普通 POST 表单会导致 : "Templa

我想在 angular 2 模板中有一个纯 html 表单(不依赖 javascript 执行 POST)。

具有以下纯 POST 形式:

<form action="connect/facebook" method="POST">
  <input type="hidden" name="scope" value="public_profile,email"/>
  <button type="submit">Connect to FB</button>
</form>

在 html 模板中导致以下错误:

 Template parse errors: No provider for ControlContainer ("
    <h2 class="text-xs-center">{{'SIGNIN_FORM.TITLE' | translate}}</h2>

    [ERROR ->]<form action="connect/facebook" method="POST">
    <input type="hidden" name="scope" value="pub"): SigninComponent@6:8 ; Zone: <root> ; Task: Promise.then ; Value:
 Error: Template parse errors: No provider for ControlContainer ("
   <h2 class="text-xs-center">{{'SIGNIN_FORM.TITLE' | translate}}</h2>

   [ERROR ->]<form action="connect/facebook" method="POST">
   <input type="hidden" name="scope" value="pub"): SigninComponent@6:8
    at TemplateParser.parse (http://localhost:8080/main.bundle.js:20619:19)
    at RuntimeCompiler._compileTemplate (http://localhost:8080/main.bundle.js:42414:51)
    at http://localhost:8080/main.bundle.js:42337:83
    at Set.forEach (native)
    at compile (http://localhost:8080/main.bundle.js:42337:47)
    at ZoneDelegate.invoke (http://localhost:8080/main.bundle.js:60992:29)
    at Zone.run (http://localhost:8080/main.bundle.js:60885:44)
    at http://localhost:8080/main.bundle.js:61240:58
    at ZoneDelegate.invokeTask (http://localhost:8080/main.bundle.js:61025:38)
    at Zone.runTask (http://localhost:8080/main.bundle.js:60925:48)

有人可以帮忙吗?

最佳答案

添加 ngNoForm 以获得 native 行为:

<form ngNoForm action="connect/facebook" method="POST">

关于angular - 在 Angular 2 模板中使用普通 POST 表单会导致 : "Template parse errors: No provider for ControlContainer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39453681/

相关文章:

SQL - 如何在 UNION 查询中排序

php - 使用 openssl_encrypt 代替 Mcrypt 进行 3DES-ECB 加密

scala - Akka 流 : Can not write to file sink

apache-spark - 如何在范围内划分数字列并为 apache spark 中的每个范围分配

html - 隐藏来自 HTML 电子邮件的预览文本的内容

regex - 如何在不使用 json 库和 json 解析器的情况下解析 json 文件

fortran - IF 和 ENDIF 之前的 # 是什么意思

json - 使用 JOLT 转换重命名嵌套数组中的字段

python - 如何为使用 gmail 发送的电子邮件添加主题?

ruby-on-rails - 使用 Passenger/Capistrano 部署到 Nginx