For ionic 1 i have done like ng-if="$index % 3 === 0"
But i need to load the data dynamically in grid view with two col in one row. How can i do that. i tried below code :
in my schudle.ts :
ResourceData = [{ name: "ksjs" },{ name: "daa" },{ name: "das" }, {name: "das" }, {name: "Computer Science" }, { name: "Moc" }]
My html :
<div class="item item-body no-padding" style="border-width: 0px !important; overflow-y:hidden;height: 65%;">
<div class="row no-padding" style="height: 65%;" *ngFor="let data of ResourceData" *ngIf="index % 2 == 0">
<div class="col col-50 custom-design2" style="background: url(url) no-repeat center;background-size: cover;">
<div class="custom-design1"><span class="grid-title">{{data[index].name}}</span></div>
</div>
<div class="col col-50 custom-design2" style="background: url(url) no-repeat center;background-size: cover;">
<div class="custom-design1"><span class="grid-title">{{data[index + 1].name}}</span></div>
</div>
</div>
</div
But it din work . May be that ngif
may be wrong. please tell me how can i solve this.
i need like this :
as fa
fas faaf
faf faf
fafa fafaf
So two col per row. Please tell me what i am doing wrong !!
Thanks
ionic 1
<div class="row no-padding" ng-repeat="mydash in Data" ng-if="$index % 3 === 0">
<div class="col col-30 custom-design2" style="background: url({{Data[$index].Image}}) no-repeat center;background-size: cover;" ng-click="changestate(Data[$index])" ng-if="$index < Data.length">
<div class="custom-design1"><span class="grid-title">{{Data[$index].name}}</span></div>
</div>
<div class="col col-30 custom-design2" style="background: url({{Data[$index + 1].Image}}) no-repeat center;background-size: cover; " ng-click="changestate(Data[$index + 1])" ng-if="$index + 1 < Data.length">
<div class="custom-design1"><span class="grid-title">{{Data[$index + 1].name}}</span></div>
</div>
<div class="col col-30 custom-design2" style="background: url({{Data[$index + 2].Image}}) no-repeat center;background-size: cover; " ng-click="changestate(Data[$index + 2])" ng-if="$index + 2 < Data.length">
<div class="custom-design1"><span class="grid-title">{{Data[$index + 2].name}}</span></div>
</div>
</div>
You are using two structural directives in the same tag.Both
*ngFor
and*ngIf
in onediv
.Use ng-container
You can also get index by appending
let i =index
in*ngFor
.