angular – formGroup需要一个FormGroup实例

前端之家收集整理的这篇文章主要介绍了angular – formGroup需要一个FormGroup实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Plunkr上有一个Angular 2 RC4基本表单示例,似乎抛出以下错误(在Chrome DEV控制台中)

这是傻瓜

https://plnkr.co/edit/GtPDxw?p=preview

错误

browser_adapter.ts:82 EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./App class App - inline template:1:7
ORIGINAL EXCEPTION: formGroup expects a FormGroup instance. Please pass one in.
           Example: <form [formGroup]="myFormGroup">

ORIGINAL STACKTRACE:
Error: formGroup expects a FormGroup instance. Please pass one in.
           Example: <form [formGroup]="myFormGroup">

    at new BaseException (https://npmcdn.com/@angular/forms@0.2.0/src/facade/exceptions.js:27:23)
    at FormGroupDirective._checkFormPresent (https://npmcdn.com/@angular/forms@0.2.0/src/directives/reactive_directives/form_group_directive.js:110:19)
    at FormGroupDirective.ngOnChanges (https://npmcdn.com/@angular/forms@0.2.0/src/directives/reactive_directives/form_group_directive.js:39:14)
    at DebugAppView._View_App0.detectChangesInter
您的代码中存在一些问题

>< div [formGroup] =“form”>在< form>之外标签
>< form [formGroup] =“form”>但是包含FormGroup的属性名称是loginForm,因此它应该是< form [formGroup] =“loginForm”>
> [formControlName] =“dob”,它传递不存在的属性dob的值.你需要的是传递字符串dob,如[formControlName] =“’dob’”或更简单的formControlName =“dob”

Plunker example

原文链接:https://www.f2er.com/angularjs/143356.html

猜你在找的Angularjs相关文章