指令[(ngModel)] =在rc5中不再起作用 [英] The directive [(ngModel)]= not working anymore in rc5
问题描述
ngModel抛出异常,在rc4中可以正常工作
ngModel is throwing exceptions, this worked fine in rc4
<input [(ngModel)]="par.name" placeholder="name" />
这些是例外:
zone.js@0.6.12?main = browser:260未捕获的异常:错误 ./CommunityListComponent类CommunityListComponent-内联 模板:10:27原始例外:没有用于表单控件的值访问器 带有未指定名称的原始堆栈:错误:无值访问器 用于具有未指定名称的表单控件
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导入您的引导程序模块来解决,然后它将对所有组件可用.
can also solve by importing FormsModule into your bootstrap module, then it will be available to all components.
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 { }
这篇关于指令[(ngModel)] =在rc5中不再起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!