DEV Community

Discussion on: Component Communication in Angular (Parent to Child & Child to Parent)

Collapse
 
giacorsa profile image
Gianni

Hi anubhab,
I have some probem in case of passing array from parent to child component:
Error: src/app/movie-dashboard/movie-dashboard.component.html:5:19 - error TS2322: Type '{ movieName: string; genre: string; }[]' is not assignable to type 'string[]'.
Type '{ movieName: string; genre: string; }' is not assignable to type 'string'.
5
~~~~~
src/app/movie-dashboard/movie-dashboard.component.ts:7:16
7 templateUrl: './movie-dashboard.component.html',
~~~~~~~~~~~~~~
Error occurs in the template of component MovieDashboardComponent.
it semes that it doesn't recognize myFavoriteMovies as an array of Strings, CAn you help me pls ? thxs

Collapse
 
anubhab5 profile image
Anubhab Mukherjee

Thanks a lot Gianni. You pointed out a mistake that I made while typing.
I have fixed it.
The updated code -
myFavoriteMovies = [ 'Encanto',
'Spider-Man: No Way Home',
"Harry Potter and the Sorcerer's Stone" ];

Please let me know if you still find the issue.

I would be happy to help...

Collapse
 
giacorsa profile image
Gianni

many thanks, now it works !! :-)