Ionic 2新行如果索引%3 == 0

时间:2017-07-05 11:28:55

标签: angularjs ionic-framework ionic2

我有一个离子网格,里面有3个foreach循环 最外层的循环看起来像这样:

<ion-content padding>
    <ion-grid>
        <ion-row>
            <ion-col>
                <ion-row>
                    <ion-col *ngFor="let field1 of gs.fields; let x = index; trackBy: trackByFn">
                        <!-- More Foreach Loops inside each other-->  
                    </ion-col>
                </ion-row>
            </ion-col>
        </ion-row>
    </ion-grid>
</ion-content>

但我想每次x%3 == 0时得到一个新行[如果我保持第一个在循环之外我需要x%3 == 0&amp;&amp; x!= 0] 我希望保持循环内的所有内容相同而不是复制代码
底部的屏幕

我的第一个想法是做类似的事情:

<ion-content padding>
    <ion-grid>
        <ion-row>
            <ion-col>
                <ion-row>
                    <ion-col *ngFor="let field1 of gs.fields; let x = index; trackBy: trackByFn">
                        <ion-row *ngIf="x%3==0 && x!=0">
                            <!-- More Foreach Loops inside each other-->  
                        </ion-row *ngIf="x%3==0 && x!=0">
                    </ion-col>
                </ion-row>
            </ion-col>
        </ion-row>
    </ion-grid>
</ion-content>

x在0到8的范围内运行,因此</ion-row *ngIf="x%3==0 && x!=0">作为结束标记应该没问题,因为我关闭了外部foreach循环外面的离子行。但这不是装载。

如何:
How it is 我希望如何:
How i want it to be

<ion-content padding>
    <ion-grid>
        <ion-row>
            <ion-col *ngFor="let field1 of gs.fields; let x = index; trackBy: trackByFn">
                <div *ngIf="gs.won_fields[x] == false" [ngClass]="{'bordern':x%2==0,'bordernplus1':x%2!=0}">
                    <ion-col *ngFor="let field2 of field1; let y = index; trackBy: trackByFn">
                        <ion-row>
                            <ion-col class="ctr fc tile" *ngFor="let tile of field2; let z = index; trackBy: trackByFn" (click)="playerClick(x,y,z)">
                                <span class="ctr" [ngClass]="{'player1': tile==1, 'player2' : tile==2}">{{(tile==0)? ' ': ((tile==1)? 'x' : 'o')}}</span>
                            </ion-col>
                        </ion-row>
                    </ion-col>
                </div>
                <!-- Wenn Feld gewonnen x oder o eintragen  -->
                <span class="ctr tile" *ngIf="gs.won_fields[x] != false" [ngClass]="{'bordern':x%2==0,'bordernplus1':x%2!=0}" [ngClass]="{'player1': gs.won_fields[x]===1, 'player2' : gs.won_fields[x]===2}">{{(gs.won_fields[x]==1)? 'x' : 'o'}}</span>
            </ion-col>
        </ion-row>
    </ion-grid>
</ion-content>

1 个答案:

答案 0 :(得分:0)

content('See the latest build in the jenkins job here https://jenkins.xyz.com/job/${jobName}/ <pre> ${BUILD_LOG, maxLines=30, escapeHtml=false} </pre>') 申请整个元素,而不仅仅是开放或关闭代码。 你可以这样做:

ngIf