Я обновил вашу игровую площадку здесь .Добавьте это в html
<StackLayout >
<Button text="Button1" (tap)="onButton1Tap()"></Button>
<Button text="Button2" (tap)="onButton2Tap()"></Button>
<GridLayout rows="{{genRows()}}" [columns]="genCols()" height="400" width="400">
<!--How should I implement here ?-->
<Label *ngFor="let item of gridData; index as i; " row="{{item.row}}"
col="{{item.col}}" text="{{item.label}}"></Label>
</GridLayout>
и в yout .ts
cols = '*';
rowsCount = "*";
gridData1 = [
{ label: 'Grid1_Label1', id: '-1', row: '0', col: '0' },
{ label: 'Grid1_Label2', id: '-2', row: '1', col: '0' },
{ label: 'Grid1_Label3', id: '-1', row: '2', col: '0' },
{ label: 'Grid1_Label4', id: '-2', row: '3', col: '0' }
];
gridData2 = [
{ label: 'Grid1_Label1', id: '-1', extraProperty: 'Grid1_Label1_Extra1' },
{ label: 'Grid1_Label2', id: '-2', extraProperty: 'Grid1_Label1_Extra2' }
];
constructor() {
}
genRows() {
for (let i = 1; i < this.gridData1.length; i++) {
this.cols += ",*";
}
return this.cols;
// console.log(this.cols);
}
genCols() {
for (let i = 1; i < this.gridData1.length; i++) {
this.rowsCount += ",*";
}
return this.rowsCount;
}