模板驱动型表单-登录
都写到模板
响应式表单-注册
一些移动到
页面<form [formGroup]="userForm"
组件类
ngOnInit() {
this.buildForm();
}
buildForm(): void {
this.userForm = this.fb.group({
"userName": [
.............
动态表单-用户资料修改
user-profile.component.ts中,代码生成
@Input() fields: FieldBase<any>[] = [
new Image({
src: "assets/imgs/angular2-small.png"
}),
new Textbox({
label: "头像:",
placeholder: "上传头像",
type: "file"
}),
.................
页面显示
<div *ngFor="let field of fields" class="form-group">
<form-control [form]="form" [field]="field"></form-control>
</div>
自定义校验规则指令
————————————————————————————————
——————————————————
国际化