我有一个由父组件和两个子组件组成的角度项目 . 父级是模态,而2子组件是接受来自用户/或表单的数据的面板 . 使用父组件/模态内的下一个和后退按钮执行两个子组件之间的导航 . 现在我希望子1表单组件中的数据成为child2组件的初始值 . 如果用户返回到第一个子表单组件并更改child1中的表单值,则更改将反映到child2表单初始值 . 我能够将数据从child1表单组件传递给父组件,但很难将该数据从父组件传递给子组件2作为初始值 . 我尝试使用ngOnInit中的patchValue将父数据传递给child2但是我'm getting an error like "name is not a proprty of undefined' . 下图显示了我真正想要实现的目标 .
enter image description here

代码在这里:

export class Child2Component{
    @Input() person;

    child2Form : FormGroup; 
    ngOnit(){
       this.child2Form= this.fb.group({
           name: ''
       });
       this.child2Form.patchValue({
          name: this.person.name
       });
    }

}