I'm trying to make grid-row and grid-column to be dynamically populated from API.
component.html
<div *ngFor = "let element of elements">
<div [ngStyle]="styleObject(element.Row,element.Column)">{{element['Tool Name']}}</div>
</div>
component.ts
styleObject(row : String,Column:String): Object {
let obj :Object;
obj = {'grid-row':''+Number(row),'grid-column':''+Number(Column)};
console.log(obj);
return obj.toString;
}
This way in the console it is printing but it's not reflecting in UI. Console Image
It worked properly when I tried to populate the data manually as
<div [ngStyle]="{'grid-column':'9','grid-row':'9'}">{{element['Tool Name']}}</div>
In the Inspect Element mode, the attribute is showing as enter image description here
Where am I making mistake? Thanks in advance.