1<div class="yourCssClass" *ngIf="this.isButtonVisible" (click)="this.isButtonVisible = false">
2...
3</div>
4
5Your TypeScript
6
7export class AppComponent {
8 private isButtonVisible = true;
9}
1<div *ngIf="div1">
2 ABC
3</div>
4<div *ngIf="div2">
5 DEF
6</div>
7<div *ngIf="div3">
8 GHI
9</div>
10<button (click)="div1Function()"></button>
11<button (click)="div2Function()"></button>
12<button (click)="div3Function()"></button>
13
14
15in .ts file
16
17
18 div1:boolean=true;
19 div2:boolean=true;
20 div3:boolean=true;
21
22 div1Function(){
23 this.div1=true;
24 this.div2=false;
25 this.div3=false
26 }
27
28 div2Function(){
29 this.div2=true;
30 this.div1=false;
31 this.div3=false
32 }
33
34 div3Function(){
35 this.div3=true;
36 this.div2=false;
37 this.div1=false
38 }