A function in my codebase is responsible for toggling a specific section within a div element.
Currently, there are a total of 3 sections available in the app.
The functionality is implemented in the app.component.ts file:
show = false;
toggle() {
this.show = !this.show;
}
In the app.component.html file:
<div>
<div *ngIf="show">
<div>One</div>
</div>
<button type="button" toggle()"></button>
</div>
<div>
<div *ngIf="show">
<div>Two</div>
</div>
<button type="button" toggle()"></button>
</div>
<div>
<div *ngIf="show">
<div>Three</div>
</div>
<button type="button" toggle()"></button>
</div>
As it stands now, all three sections toggle visibility when clicking on any button.
Is there a way to modify this behavior so that only the corresponding section toggles when clicking on its respective button with *ngIf="show"
?