No directive with “exportAs” set to “ngModel” angular 6

旧巷老猫 提交于 2019-12-24 10:46:07

问题


I'm trying to validate a form with angular 6. Here's my PUG code:-

.form-group
  input.input-lg.form-control(type="text", 
    placeholder="Your firstname",
    name="fname",
    #fname="ngModel", 
    required)
    .alert.alert-danger(*ngIf="fname.invalid")
    p([hidden]="!fname.errors.required") First name is required`

and I get this error:

Uncaught Error: Template parse errors: There is no directive with "exportAs" set to "ngModel" (" ]#fname="ngModel" required="required"/>

I've already imported the FormsModule in the app.module.ts.


回答1:


I had a simmilar problem which I asked about in this question. Check the comment section. My problem was that i forgot to add the imports: [FormsModule, ... in the app.module.ts. Maybe this is your problem too.



来源:https://stackoverflow.com/questions/52027573/no-directive-with-exportas-set-to-ngmodel-angular-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!