在 Angular 2 模板中使用普通 POST 形式会导致:"Template parse errors: No provider for ControlContainer"
Using a plain POST form within an Angular 2 template results in: "Template parse errors: No provider for ControlContainer"
我想在 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)
有人可以帮忙吗?
您的应用程序模块中似乎缺少 FormsModule
提供程序,尝试添加:
import {FormsModule} from '@angular/forms';
到您的 @NgModule
,别忘了将它也添加到 imports
。
添加 ngNoForm
以获得本机行为:
<form ngNoForm action="connect/facebook" method="POST">
我想在 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)
有人可以帮忙吗?
您的应用程序模块中似乎缺少 FormsModule
提供程序,尝试添加:
import {FormsModule} from '@angular/forms';
到您的 @NgModule
,别忘了将它也添加到 imports
。
添加 ngNoForm
以获得本机行为:
<form ngNoForm action="connect/facebook" method="POST">