Looking to add unique background colors using ng-style
. Each row in the list is created with ngFor
, giving each item its own distinct background color.
<ion-item class="category-list" *ngFor="let item of character['items']">
<ion-avatar item-left>
<i class="icon" [ngStyle]="{'background-color': item.bgcolor}"><img src="../img/icons/category/{{item.img}}.png"></i>
</ion-avatar>
<h2>{{item.category}}</h2>
</ion-item>
Here's a snippet from the Typescript.ts:
var characters = [
{
name: 'Gollum',
quote: 'Sneaky little hobbitses!',
items: [
{ bgcolor: 'fb9667', img: 'airTicket', category: 'Air tickets' },
{ bgcolor: '000000', img: 'airTicket', category: 'Beauty/Fitness'},
{ bgcolor: '0b9660', img: 'airTicket', category: 'Bike'}
]
},
]
Having trouble applying color codes to the list—any advice?