我已经通过There is no directive with "exportAs" set to "ngForm",但是仍然无法解决以下错误。
错误:
var content = this.templateTarget.innerHTML
this.bodyTarget.insertAdjacentHTML('beforeend', content)
myForm
ERROR Error: Uncaught (in promise): Error: Template parse errors:
There is no directive with "exportAs" set to "ngForm" ("<div>
<form novalidate [ERROR ->]#f=ngForm [formGroup]="pForm">
<div class="dxp-input">
<label class="dxp-input"): ng:///StudentModule/StudentComponent.html@1:21
Can't bind to 'formGroup' since it isn't a known property of 'form'. ("<div>
<form novalidate #f=ngForm [ERROR ->][formGroup]="pForm">
<div class="dxp-input">
<label class="dxp-inputbox-label">"): ng:///StudentModule/StudentModule/StudentComponent.html@1:32
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("gth="0" maxlength="100"
AppModule.java
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [
AppComponent,
TemplateComponent,
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }