Home > Back-end >  How can i make a property value inside an ngfor independent, between two child components
How can i make a property value inside an ngfor independent, between two child components

Time:03-11

When clicking on a car brand, i need it to be displayed on the bottom, where it has the name of the person, and its favorite car, cliked above, but when i click on one, the car brand is repeated between all items of the ngfor.

stackblitz example of it: image example

CodePudding user response:

Just use input when rendering every component in your ngfor. https://angular.io/guide/inputs-outputs

CodePudding user response:

Use a dictionary to hold the values for each person using their name as the key. See the edited stackblitz.

https://stackblitz.com/edit/angular-ivy-pachaq?file=src/app/app.component.ts

  • Related