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>
怎么报错了呢?
学会搜索,这种明显的错误一搜索就有。
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
]
嗯是的但是一开始不知道@NgModule({ imports: [ FormsModule ]这个是在那里引用现在知道了
ng-model不应该是这样用的么:<input type="text" ng-model="zx">
双向绑定