欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

解决angular2在双向数据绑定时[(ngModel)]无法使用的问题

程序员文章站 2023-09-07 23:27:20
angular2在双向数据绑定时[(ngmodel)]无法使用,出现的错误是: can't bind to 'ngmodel' since it isn't a...

angular2在双向数据绑定时[(ngmodel)]无法使用,出现的错误是:

can't bind to 'ngmodel' since it isn't a known property of 'input'.

解决办法:

在文件 app.component.ts 中引入ngmodel

具体为:

添加两行代码:

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

formsmodule,

位置如下:

解决angular2在双向数据绑定时[(ngModel)]无法使用的问题

以上这篇解决angular2在双向数据绑定时[(ngmodel)]无法使用的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。