Dev Teywa

Dev Teywa

  • NA
  • 250
  • 37.9k

show and hide element for each clicked button in angular2+

Feb 4 2018 2:44 PM
hi,
i have a problem when i click in button  i want to show just element related with button but in my script when i click in the button i show the other elements
how can i solve this please ?
and thanks in advance  
 
 
  1. <div  *ngFor="let pa of p.phases">  
  2.       <div class="col-md-2">  
  3.           <button class="btn btn-default" (click)="showlivrable=!showlivrable" style="width: 133px;height:133px;" >  
  4.           <img *ngIf='pa.libelle == "demarrage"' src="./assets/img/icons/icon_demarrage.png"/>  
  5.           <img *ngIf='pa.libelle == "planification"' src="./assets/img/icons/icon_planif.png"/>  
  6.           <img *ngIf='pa.libelle == "exécution"' src="./assets/img/icons/icon_execution.png"/>  
  7.           <img *ngIf='pa.libelle == "Suivi"' src="./assets/img/icons/icon_suivi.png"/>  
  8.           <img *ngIf='pa.libelle == "Clôture"' src="./assets/img/icons/icon_cloture.png"/>  
  9.           <img *ngIf='pa.libelle == "Bilan d’efficacité"' src="./assets/img/icons/icon_bilan.png"/>  
  10.           <br>  
  11.               {{pa.libelle}}<br><br>  
  12.               <span class="par" *ngIf='pa.libelle == "demarrage"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  13.               <span class="par" *ngIf='pa.libelle == "planification"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  14.               <span class="par" *ngIf='pa.libelle == "exécution"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  15.               <span class="par" *ngIf='pa.libelle == "Suivi"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  16.               <span class="par" *ngIf='pa.libelle == "Clôture"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  17.               <span class="par" *ngIf='pa.libelle == "Bilan d’efficacité"'>Du: {{pa.du}} <br> Au: {{pa.au}}</span>  
  18.           </button>  
  19.       </div>  
  20.       <div *ngIf="showlivrable" style="display:inline-block">  
  21.               <p *ngIf='pa.libelle == "demarrage"'>  
  22.                   <span *ngFor="let ld of p.livrablesDemmarage" style="float:left;">  
  23.                       {{ld.title}}<br>{{ld.description}}<br><br>  
  24.                   </span>  
  25.               </p>  
  26.               <p *ngIf='pa.libelle == "planification"'>  
  27.                       <span *ngFor="let ld of p.livrablesPlanification" style="float:left;">  
  28.                           {{ld.title}}<br>{{ld.description}}<br><br>  
  29.                       </span>  
  30.               </p>  
  31.               <p *ngIf='pa.libelle == "exécution"'>  
  32.                       <span *ngFor="let ld of p.livrablesExecution" style="float:left;">  
  33.                           {{ld.title}}<br>{{ld.description}}<br><br>  
  34.                       </span>  
  35.               </p>  
  36.               <p *ngIf='pa.libelle == "suivi"'>  
  37.                       <span *ngFor="let ld of p.livrablesSuivi" style="float:left;">  
  38.                           {{ld.title}}<br>{{ld.description}}<br><br>  
  39.                       </span>  
  40.               </p>  
  41.               <p *ngIf='pa.libelle == "Clôture"'>  
  42.                       <span *ngFor="let ld of p.livrablesCloture" style="float:left;">  
  43.                           {{ld.title}}<br>{{ld.description}}<br><br>  
  44.                       </span>  
  45.               </p>  
  46.               <p *ngIf='pa.libelle == "Bilan d’efficacité"'>  
  47.                       <span *ngFor="let ld of p.livrablesBilan" style="float:left;">  
  48.                           {{ld.title}}<br>{{ld.description}}<br><br>  
  49.                       </span>  
  50.               </p>  
  51.   
  52.       </div>  
  53.        
  54. t;/div>  
 

Answers (1)