2016-11-20 67 views
0

请,我卡在这里球员;我在一天后得到这个错误,它是推动我疯了,而开发一个应用程序Angular2稳定版本):Angular2中的FormGroup绑定错误

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"") 

围绕搜索时怪异的一部分,有一个明显的只有一个解决方案,在Module file正在做

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

。我做到了:

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 {} 

结合的错误是在LcFormComponent的HTML,其他部件工作平稳但在这里我真的不知道问题出在哪里。 这里是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 { 

// .... 

} 

任何帮助吗?

+0

你是不是指'[formGroup] =“...”'? – jonrsharpe

+0

是的,的确是[formGroup] –

+1

在html中是否使用小写'[formGroup]'或大写'[FormGroup]'? – ulubeyn

回答

1

您在html中使用的是[FormGroup],应改为[formGroup]