没有带有"exportAs"的指令设置为"ngModel"角度6 [英] No directive with "exportAs" set to "ngModel" angular 6

查看:211
本文介绍了没有带有"exportAs"的指令设置为"ngModel"角度6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证角度为6的表格. 这是我的PUG代码:-

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`

我得到这个错误:

未捕获的错误:模板解析错误:没有指令与 "exportAs"设置为"ngModel"(]#fname =" ngModel"required =" required"/>

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

我已经将FormsModule导入了app.module.ts中.

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

推荐答案

我遇到了一个类似的问题,我在

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.

这篇关于没有带有"exportAs"的指令设置为"ngModel"角度6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆