How to manipulate DIV with angle 2

0

I have 2 DIVs and would like to manipulate them with buttons. I have 2 DIVs. When one appears the other is hidden, vice versa. Can someone help me ? my version of Angular is 5.

   Function1    Function2    

            content -2     
asked by anonymous 24.09.2018 / 23:00

1 answer

1

app.component.ts

public div: boolean = true;

app.component.html

<a (click)="div = 1">div1 show</a>
<div *ngIf="div">
 div 1 
</div>
<br>
<a (click)="div = 0">div2 show</a>
<div *ngIf="!div">
 div 2
</div>

You can use this function (click)="div = 0; funcao()" ou (click)="funcao()" funcao(){ this.div = !this.div; }

    
24.09.2018 / 23:42