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

查看:32
本文介绍了没有带有“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"/>

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

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

推荐答案

我有一个类似的问题,我在 这个问题.检查评论部分.我的问题是我忘记在 app.module.ts 中添加 imports: [FormsModule, ....也许这也是你的问题.

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天全站免登陆