The Angular docs in the Lifecycle Hooks section includes the wait a tick hack. I’m not sure why you are recommending against it? After a day of research I can’t figure out how to re-architect my simple setup anyway. Just an edit form child getting loaded into a parent and then loading the data into the form. When the fuction for loading the data is wrapped in setTimeout it works fine:
ngAfterViewInit() {
setTimeout(() => {
this.fetchMember();
});
}Per https://angular.io/guide/lifecycle-hooks#afterview
Abide by the unidirectional data flow rule
…
Why does the doSomething() method wait a tick before updating comment?
Angular’s unidirectional data flow rule forbids updates to the view after it has been composed. Both of these hooks fire after the component’s view has been composed.
This is all the child component does, besides set some properties:
ngOnInit() {
this.createForm();
}
// The reactive model that is bound to the form.
createForm(): void {
this.addEditMemberForm = this.fb.group({
firstName: ['', Validators.required],
lastName: ['', Validators.required],
mainSkillTitle: ['', Validators.required],
mainSkills: ['', Validators.required],
otherSkills: ['', Validators.required],
links: ['', Validators.required],
country: ['', Validators.required],
email: ['', Validators.required]
});
}…