I have few buttons and div elements. divs are hidden. I want to reveal the specific div, when the specific button is clicked.
For example: You click first button - only first div appears (appears by changing his class).
Code: app.component.html
<button class="BUTTON" (click)="isHidden = !isHidden">
</button>
<div class="ELEMENTTOSHOW" [ngClass]="{ 'subMenuShow':isHidden }">first
</div>
<button class="BUTTON" (click)="isHidden = !isHidden">
</button>
<div class="ELEMENTTOSHOW" [ngClass]="{ 'subMenuShow':isHidden }">second
</div>
app.component.ts
export class AppComponent {
isHidden = false;
}
This solution is wrong because when I click e.g. first BUTTON then both divs ELEMENTTOSHOW appear. It shouldnt work like that, it should only work on a specific div.
Any help appreciated.
Edit: here is my code preview on plunker:
Its not my whole app, only the mentioned, VERY simplified part.
I have added AngularJS tag, because you can give me a solution related with angular1 and I will just rewrite it into angular2.