I would like to have a plain html form (that does a POST without relying on javascript) within a angular 2 template.
Having the following plain POST form:
<form action="connect/facebook" method="POST">
<input type="hidden" name="scope" value="public_profile,email"/>
<button type="submit">Connect to FB</button>
</form>
within the html template results in the following 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 ; 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)
Can someone please help?
添加ngNoForm
以获取本机行为:
<form ngNoForm action="connect/facebook" method="POST">
It looks like FormsModule
provider is missing in your application module, try add:
import {FormsModule} from '@angular/forms';
to your @NgModule
, don't forget to add it to imports
also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.