当使用 ngModel 是报错
angular There is no directive with exportAs set to ngModel
代码:
<input name="username" #username="ngModel" />
解决:
1、首先在app.module.ts中引入FormsModule
import { FormsModule } from '@angular/forms';
并在NgModule的imports中引入 FormsModule
2、添加[(ngModel)]
<input name="username" [(ngModel)]="username" #username="ngModel" />