Skip to content Skip to sidebar Skip to footer

How To Pass Property From Parent To Child Component In Angular 8?

I have an array of DossierEntry and if you select one item that you have to go to that item. But if you now select a item you will get an error like this: dossier-correspondence-i

Solution 1:

You should store your selected entry somewhere in your parent component

selectedEntry: DossierEntry;
selectEntry(entry: DossierEntry): void {
   this.selectedEntry= entry;
}

Also, you should use (click) event instead of (onClick) in angular. Use the selectEntry method on click.

And your call to child component should have an @Input (see https://angular.io/guide/component-interaction)

When calling child component, check nullability of your selectedEntry, and you'll be fine for the error you're having

Post a Comment for "How To Pass Property From Parent To Child Component In Angular 8?"