拜托,我被困在这里了;一天后我遇到了这个错误,它在开发Angular2
应用程序(稳定版)时让我发疯:
Error: Template parse errors:
Can't bind to 'FormGroup' since it isn't a known property of 'form'.
("<form name="pageForm"
[ERROR ->][FormGroup]="pageForm"
class="lc-edit-page" novalidate>
<div class="row">
<div class="col-lg-6"")
奇怪的部分是在四处搜索时,显然只有一个解决方案正在做
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
在Module file
. 我做的 :
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { UsersListComponent } from './modals';
import { LcFormComponent } from './lc-form';
import { AddUComponent } from '../../../../+u/shared/components';
import { UIRouterModule } from 'ui-router-ng2';
import { TranslateModule } from 'ng2-translate';
@NgModule({
declarations: [
LcFormComponent,
UsersListComponent
],
imports: [
FormsModule,
BrowserModule,
UIRouterModule,
TranslateModule,
LcFormComponent,
UsersListComponent,
ReactiveFormsModule
],
providers: [],
exports: [
FormsModule,
BrowserModule,
UIRouterModule,
TranslateModule,
LcFormComponent,
UsersListComponent,
ReactiveFormsModule
],
entryComponents:
[
AddUComponent,
UsersListComponent
]
})
export class ParModule {}
绑定错误在 HTML 中LcFormComponent
,在其他组件中它工作顺利,但在这里我真的不知道问题出在哪里。这是LcFormComponent.ts
导入部分:
import { Input, Component, AfterContentInit } from '@angular/core';
import { FormBuilder, FormGroup, FormControl, Validators, NgForm } from '@angular/forms';
import * as lodash from 'lodash';
import { TranslateService } from 'ng2-translate';
import { NotificationsService } from 'angular2-notifications';
import { NgbModal, NgbModalRef, NgbModalOptions } from '@ng-bootstrap/ng-bootstrap';
import { UsersListComponent } from '../modals';
import { AddUComponent } from '../../../../../+users/shared/components/modals';
@Component({
selector: 'app-lc-form',
templateUrl: './lc-form.component.html',
styleUrls: ['./lc-form.component.scss']
})
export class LcPageComponent {
// ....
}
有什么帮助吗?