'Angular initializing form with @Input value becomes undefined on refresh

I am passing a value from my parent component to my child component using the @Input() communication method. This value is used to initialize the form.

Parent Component.html

<child [someValue]="this.randomValue"></child>

Child Component.ts

@Input() someValue: any;

form: FormGroup;

ngOnInit(){
  this.form = this.fb.group(
    value: this.fb.array([someValue])
}
  • someValue becomes undefined when page reloads... why?
  • Is there a way to make sure it's not undefined?
  • I tried to add this initialize the form in ngOnChanges which solves this problem however leads to unexpected results... such as it will always set the FormArray to this value and won't let additional values be added to the FormArray


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source