找不到错误的解决方案:formGroup需要angularJS2中的FormGroup实例

时间:2017-02-07 16:06:41

标签: validation angular

我是angularJS2的新手,我正在尝试使用angularJS2表单构建表单模板并在其中进行验证,但我遇到了一个错误,我无法得到解决方案。我试图在构造函数中包含FormBuilder.group()方法,但我没有解决问题。这是我得到的错误 enter image description here 我在plunkr更新了我的代码 以下是我的组件代码。

import { Component } from '@angular/core';
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';

@Component({
    selector: 'policy-form',
    templateUrl: '../../templates/policy.template.html'
})
export class PolicyComponent {
    policyForm: FormGroup;
    constructor(private fb: FormBuilder) {
        this.policyForm = fb.group({
            insuredName: ['', Validators.required],
            insuredAddress: ['', Validators.required],
            taxationType: ['', Validators.required],
            lastVersion: ['', Validators.required],
            renewal: ['', Validators.required],
            commissionType: ['', Validators.required],
            balanceDue: ['', Validators.required],
            suspenseAmount: ['', Validators.required],
            policyNumber: ['', Validators.required],
            policyType: ['', Validators.required],
            underwriter: ['', Validators.required],
            policyYear: ['', Validators.required],
            paymentPlan: ['', Validators.required],
            receivedDate: ['', Validators.required],
            enteredDate: ['', Validators.required],
            selectDate: ['', Validators.required],
            issueddate: ['', Validators.required],
        });
    }

    SubmitPolicy(value: any) {

    }
}

0 个答案:

没有答案