TypeScript-'s Angular Framework Error - “There is no directive with exportAs set to ngForm”

前端 未结 22 1662
轻奢々
轻奢々 2020-12-04 09:18

I keep getting this error while using TypeScript\'s Angular2-forms framework:

There is no directive with \"exportAs\" set to \"ngForm

22条回答
  •  离开以前
    2020-12-04 09:40

    This error also occurs if you are trying to write a unit test case in angular using jasmine.

    The basic concept of this error is to import FormsModule. Thus, in the file for unit tests, we add imports Section and place FormsModule in that file under

        TestBed.configureTestingModule
        For eg: 
        TestBed.configureTestingModule({
            declarations: [ XYZComponent ],
            **imports: [FormsModule]**,
        }).compileComponents();
    

提交回复
热议问题