export class UpdateUserComponent {
registerForm: FormGroup;
public users:Array<User> = [];
public clientName: string;
public password: string;
constructor(
private formBuilder: FormBuilder,
private _userService:UserService,
) {}
ngOnInit(){
this._userService.edit(0).subscribe(res => {
let users = <User[]>res;
this.clientName = res.clientName;
console.log(this.clientName);
});
this.registerForm.controls['clientName'].setValue(this.clientName);
this.registerForm = this.formBuilder.group({
'clientName': [this.clientName],
'email': [''],
'phone': [''],
'password': ['']
});
}
}
Me sale que es undefined
el this.clientName
del formBuilder
.
¿Como lo puedo hacer?
Gracias!