* ngSwitchCase不适用于动态添加的离子段

时间:2017-07-31 12:29:09

标签: angular typescript ionic2

我无法将动态值绑定到ngSwitchCase,以在每个动态创建的离子段中获取相应的对象。 Floats是我的对象数组。根据数组中的对象数量,我可以动态添加离子段,而switchcase失败。

html的

   <ion-segment [(ngModel)]="selectedSegment" color="primary" >
        <ion-segment-button *ngFor="let item of floats" [value]="item.id" (ionChange)="changeSegment()" >
              {{item.title}}
              </ion-segment-button>
    </ion-segment>

    <div class="panel-tab">
        <div [ngSwitch]="item.id" *ngFor="let item of floats; let x = index">
          <ion-list *ngSwitchCase="'1'">{{item.title}} 
          <div>
              <div class="panel-cash">
                  <div class="panelcash-heading">Cash</div>
                  <div class="row header">  
                      <div class="col">Currency Type</div>
                      <div class="col">Sales</div>
                      <div class="col">Float</div>
                  </div>
                  <div class="row" *ngFor="let subitem of item['cash']">
                        <div class="col">{{subitem.currency}}</div> 
                        <div class="col">{{subitem.sales}}</div>
                        <div class="col">{{subitem.float}}</div>
                  </div> 
              </div>

              <div class="panel-credit">
                  <div class="panelcredit-heading">Credit Card</div>
                  <div class="row header">    
                      <div class="col">Currency Type</div>
                      <div class="col">Sales</div>
                      <div class="col">Float</div> 
                  </div>

                  <div class="row" *ngFor="let subitem of item['credit']">
                      <div class="col">{{subitem.currency}}</div>
                      <div class="col">{{subitem.sales}}</div>
                      <div class="col">{{subitem.float}}</div>
                  </div>
              </div>
        </div>
        </ion-list >
        </div>
      </div>

0 个答案:

没有答案