“exportAs”设置为“ngModel”angular4没有指令

时间:2017-11-30 13:13:31

标签: angular

我使用angular 4

时遇到了问题
  

没有指令将“exportAs”设置为“ngModel”(“”   name =“fullname”type =“text”required maxlength =“30”                     [(ngModel)=“model.fullname”[错误 - >] #fulnname =“ngModel”>

component.html

<input class="form-control" name="fullname" type="text" required maxlength="30"
 [(ngModel)="model.fullname" #fullname="ngModel">

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import {AppRoutingModule} from './app-routing.module';

import { ImageUploadModule } from 'angular2-image-upload';

import { AppComponent } from './app.component';
import { NavbarComponent } from './navbar/navbar.component';
import { HomeComponent } from './home/home.component';
import { AddComponent } from './add/add.component';
import { EditComponent } from './edit/edit.component';

@NgModule({
  declarations: [
    AppComponent,
    NavbarComponent,
    HomeComponent,
    AddComponent,
    EditComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    ImageUploadModule.forRoot(),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

1 个答案:

答案 0 :(得分:3)

您有[(ngModel)="model.fullname",但您永远不会关闭方括号[(ngModel)]="model.fullname"