2017-11-09 11 views
0

内部で動作していない私はfalseになりますボタン* ngifを使用してアイテムがNG-選択からselectdが、そのここには* ngIfモーダル

を働いていないときに叶いましたボタンのコードは

です
<button *ngIf="switch" (click)="productSaveInCart()" type="button" class="col matbuton " mat-button> 
      ADD to Cart 
     </button> 

、ここでは、モーダル

のコード全体
<ng-template #template> 
    <div class="modal-header"> 
    <h4 class="modal-title pull-left">{{modaldata.i.i}}</h4> 
    <button type="button" class="close btn pull-right" aria-label="Close" (click)="modalRef2.hide()"> 
     <span aria-hidden="true">&times;</span> 
    </button> 
    </div> 
    <div class="modal-body"> 
    <mat-card style="margin: 0; "> 
     <img height="400px" style="width: 110%" mat-card-image [src]="modaldata.i.t || '../../assets/images/noimage.png'"> 
     <mat-card-footer class="row"> 

     <h4>Extra prep. time: 1hr</h4> 

     <ng-select [allowClear]="true" [items]="items" [disabled]="disabled" (data)="refreshValue($event)" (selected)="selected($event)" 
      (removed)="removed($event)" (typed)="typed($event)" placeholder="No Date selcted"> 
     </ng-select> 
     <div *ngFor="let item of list "> 
      <h4 class="col">{{item.n}}</h4> 
      <app-dropdowns #child class="col" [listdata]="item"></app-dropdowns> 
     </div> 
     <button *ngIf="switch" (click)="productSaveInCart()" type="button" class="col matbuton " mat-button> 
      ADD to Cart 
     </button> 
     </mat-card-footer> 
    </mat-card> 
    </div> 

</ng-template> 
+0

を動作するはず? –

答えて

0

あり、これを試してみてください。

(selected)="selected($event);switch=true" 

あなたは隠されたその方法を使用することができます:それはtypescriptですが、 `switch`を制御している

[hidden]="switch" 
+0

働いてくれてありがとう@fateh mohamed。 –

+0

あなたはこれの背後にある論理を説明していただけますか? –

+0

selectイベントでスイッチを "true"に設定すると、ボタンにカートを追加すると表示されます –