How to handle DIV with angular 2

Asked

Viewed 356 times

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

1 answer

1


app.componentts.

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 this using function (click)="div = 0; funcao()" ou (click)="funcao()" funcao(){ this.div = !this.div; }

Running onlline

  • Good friend... it worked. Thank you very much.

  • Be aware that the div is not hidden but removed from the gift

  • yes, Eduardo was no longer viable to remove the gift, because he will reuse it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.