angular – 指令[(ngModel)] =在rc5中不再工作

前端之家收集整理的这篇文章主要介绍了angular – 指令[(ngModel)] =在rc5中不再工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
ngModel抛出异常,这在rc4中工作正常
<input [(ngModel)]="par.name" placeholder="name" />

这些是例外:

zone.js@0.6.12?main=browser:260 Uncaught EXCEPTION: Error in
./CommunityListComponent class CommunityListComponent – inline
template:10:27 ORIGINAL EXCEPTION: No value accessor for form control
with unspecified name ORIGINAL STACKTRACE: Error: No value accessor
for form control with unspecified name

也可以通过将FormsModule导入到引导程序模块中来解决,然后它将可供所有组件使用.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

import { AppComponent } from 'app/components/app';

@NgModule({
    imports: [BrowserModule,FormsModule],declarations: [AppComponent],bootstrap: [AppComponent]
})

export class AppModule { }

猜你在找的Angularjs相关文章