2016-11-20 29 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]