Angular2 Error: There is no directive with “exportAs” set to “ngForm”

后端 未结 11 2415
小鲜肉
小鲜肉 2020-12-01 13:33

i\'m on the RC4 and i\'m getting the error There is no directive with \"exportAs\" set to \"ngForm\" because of my template :

11条回答
  •  情深已故
    2020-12-01 14:06

    In my case I had to add FormsModule and ReactiveFormsModule to the shared.module.ts too:

    (thanks to @Undrium for the code example):

    import { NgModule }                                 from '@angular/core';
    import { CommonModule }                             from '@angular/common';
    import { FormsModule, ReactiveFormsModule }         from '@angular/forms';
    
    @NgModule({
      imports:      [
        CommonModule,
        ReactiveFormsModule
      ],
      declarations: [],
      exports: [
        CommonModule,
        FormsModule,
        ReactiveFormsModule
      ]
    })
    export class SharedModule { }
    

提交回复
热议问题