(纯属个人笔记,摘要记录)
双向绑定
[(ngModel)]是Angular的双向数据绑定的语法。
用法如下:


因为缺少FormsModule,所以当加上[(ngModule)] 之后这个应用无法工作。
AppModule:
Angular CLI 在创建项目的时候就在src/app/app.module.ts中生成一个AppModule类。这里也就是要添加FormModule的地方。
导入FormsModule:
打开AppModule(app.module.ts)并从@angular/forms库中导入FormsModule符号

然后把FormsModule添加到@NgModule元数据的imports数组中,这里是该应用所需外部模块的列表。

每个组件都必须声明在(且只能说明在)一个NgModule中。
*ngFor:是一个Angular的复写器指令。它会为列表中的每项数据复写他的宿主元素。

网友评论