Angular 6我不能将ngModel与输入标记一起使用

问题描述 投票:0回答:1

我正在使用角度6,我想使用ngModel:

<input type="text" [(ngModel)]="textValue">

所以我得到这个错误:

Can't bind to 'ngModel' since it isn't a known property of 'input'

我尝试将表单模块添加到我的login.module.ts但我收到webpack的错误:

Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined

我的依赖是:

"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0"

我该怎么做才能让mgModel在Angular 6上运行?

angular webpack
1个回答
2
投票

请在您的app.module.ts中包含以下内容:

import { FormsModule } from '@angular/forms';

@NgModule({
  imports: [FormsModule]
})

如果你没有包含在@NgModule中,你将得到上述错误

© www.soinside.com 2019 - 2024. All rights reserved.