I'm trying to dynamically add icon names to my Ionic 2 app, the reason for this is that I have a list of attributes on my model, which are dynamic, the model returns the icon name to the ionic 2 application.
This is the response I'm getting from my API.
{
"type": "searchresult",
"count": 1,
"results": [
{
"type": "room",
"url": "/api/room/1",
"id": 1,
"name": "name1",
"attributes": [
{
"type": "attribute",
"url": "/api/room/1/attribute/1",
"name": "attribute1",
"icon": "people",
"valueType": "bool",
"value": "true"
},
{
"type": "attribute",
"url": "/api/room/1/attribute/3",
"name": "attribute2",
"icon": "desktop",
"valueType": "bool",
"value": "true"
},
{
"type": "attribute",
"url": "/api/room/1/attribute/4",
"name": "attribute3",
"icon": "md-videocam",
"valueType": "bool",
"value": "true"
},
{
"type": "attribute",
"url": "/api/room/1/attribute/5",
"name": "attribute4",
"icon": "icon-chair",
"valueType": "int",
"value": "200"
}
]
}
}
This is what I have in the Ionic2 app at the moment.
<ion-row no-padding *ngFor="let att of room.attributes">
<ion-col width-20 no-padding text-center>
<ion-icon name="att.icon"</ion-icon>
</ion-col>
</ion-row>
Thank you in advance.