angular - 在 Angular 2 模板中使用普通 POST 表单会导致 : "Template parse errors: No provider for ControlContainer"

标签 angular angular2-template angular2-forms

我想在 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/

相关文章:

angular - Webpack - 在构建过程中关闭优化步骤。性能加速

jquery - Angular CLI 7.1.4 中未加载外部 JS 文件

angular - 在 Angular 2 中保留页面重新加载的数据

Angular 5 - 通过 ngModel 从子模板组件向父组件发送错误

json - 如何正确显示对象数据以在 Angular 2 中查看

javascript - Angular JS 2.0 基于用户输入切换样式表

javascript - Angular 形式不断返回 false(Angular 2)

angular - 如何构建 Angular 4.3.6 进行生产?

javascript - 转换http请求/如果成功则添加一个函数.::Typescript & Angular2

angular - angular2中的嵌套表单