首页新闻招聘找找看知识库

我在学习[(ngModel)]时报错

0
[待解决问题]

compiler.js:485 Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'.

<div>
<input type="text" [(ngModel)]="zx">
{{zx}}
</div>

怎么报错了呢?
一叶*秋的主页 一叶*秋 | 初学一级 | 园豆:12
提问于:2018-04-15 23:32
< >
分享
所有回答(2)
0

学会搜索,这种明显的错误一搜索就有。

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

 

In order to use two-way data binding for form inputs you need to import the FormsModule package in your Angular module.

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

@NgModule({
    imports: [
         FormsModule      
    ]
爱编程的大叔 | 园豆:27825 (高人七级) | 2018-04-16 10:11

嗯是的但是一开始不知道@NgModule({ imports: [ FormsModule ]这个是在那里引用现在知道了

支持(0) 反对(0) 一叶*秋 | 园豆:12 (初学一级) | 2018-04-17 23:44
0

ng-model不应该是这样用的么:<input type="text"  ng-model="zx">

mini_fan | 园豆:301 (菜鸟二级) | 2018-04-16 13:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册