1
这里IM Implementin简单AngularForm我在构成元素一流的进口这CLAAngular2反应形式验证错误control.registerOnChange不使用Angular2</p> <pre><code>export class Customer { customerName: String = "";} </code></pre> <p>功能
import { Component, OnInit } from "@angular/core"
import { NgForm, FormGroup, FormControl, Validators, FormBuilder } from "@angular/forms"
import { Customer } from "../template/customer"
@Component({
selector: "ui-view",
templateUrl: "../template/customer.html"
})
export class CustomerComponent implements OnInit {
currentCustomer: Customer = null;
customerForm: FormGroup;
custobj: Customer = new Customer();
ngOnInit(): void {
this.customerForm = new FormGroup({
customerName: new FormGroup({
})
})
}
我的HTML代码即时得到Errror作为添加formControlName是东西...即时通讯混淆我在哪里做错了,请帮助我
<form [formGroup]="customerForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" [formControlName]="customerName" />
</div>
<button type="submit" class="btn btn-success btn-block" [disabled]="!customerForms.valid">Submit</button>
</form>