Within a particular component, I have implemented some code in ngAfterViewInit:
@Input
public stringArray: string[];
public newArray: string[];
ngAfterViewInit() {
this.newArray = this.stringArray.filter(x => x.includes('a'));
}
I placed the code inside ngAfterViewInit to ensure that it waits for @Input properties to be initialized.
However, upon execution, it appears that the code within ngAfterViewInit is 'undefined.'
How can I ensure that all @Input properties are fully initialized before executing the filter operation?
UPDATE: Although the @Input property does contain data eventually, it occurs after ngAfterViewInit. How can I guarantee that my code only runs once all @Input() properties are fully initialized?