我正在学习angular6让我说我的用户模型如下。
我的用户模型如下所示
export class Report{
constructor(){
this.isActive = true;
this.createdAt = new Date();
}
id ?: string;
name = "";
custom_label_1 = "";
custom_label_2 = "";
custom_label_3 = "";
addresses: Address[];
createdAt ?: any;
updatedAt ?: any;
isActive ?: boolean;
}
在组件中,我的表单定义如下所示
this.user = new User()
this.userForm = this.fb.group(this.user);
现在我想明确地在用户模型中添加验证器而不是
this.fb.group({“name”:[“”,[Validators.requires]]})
我该如何添加验证?