Home:ALL Converter>Different view of component on every ngFor iteration

Different view of component on every ngFor iteration

Ask Time:2020-04-15T13:16:52         Author:Juhi Shaw

Json Formatter

I have an array of object and I am running ngFor on that, I want to show different view for each iteration of ngFor

const HEROES = [
    {id: 1, name:'Superman'},
    {id: 2, name:'Batman'},
    {id: 5, name:'BatGirl'},
    {id: 3, name:'Robin'},
    {id: 4, name:'Flash'}
];

Like Superman should be default view than when I click next batman should be shown the next will be batgirl and so on.

Do you have any idea?

Author:Juhi Shaw,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61221806/different-view-of-component-on-every-ngfor-iteration
yy