I have a User
form of reactive forms and I have used RxFormBuilder
from @rxweb
package , I have a user model class which contains UserInfo
object, how can I use it as a nested formgroup
?
model.ts:
import {prop,propArray } from "@rxweb/reactive-form-validators"
export class UserInfo{
@prop()
cityId: number
@prop()
countryId: number;
}
export class User{
@prop()
userId: string;
@prop()
password: string;
@prop()
securityQuestion: string;
@prop()
userInfo : UserInfo;
}
component.ts:
export class UserInfoComponent implements OnInit {
userInfoFormGroup: FormGroup
constructor(
private formBuilder: RxFormBuilder
) { }
ngOnInit() {
this.userInfoFormGroup = this.formBuilder.formGroup(User);
}
}
I want to use UserInfo
object in the user model as a nested formgroup
. How can I create nested formgroup
?
Here is a stackblitz link : https://stackblitz.com/edit/rxweb-nested-formgroup-using-model