Unable to set ion-navbar colour dynamically


I’m using a library (https://github.com/davidmerfield/randomColor) to generate a random colour per item in a list. When selecting that item in a list, I want the next page to open with the header having the same colour as the selected item.

However I’m finding that I can’t dynamically set the header background color at all. I’m trying:

<ion-navbar [style.background-color]="color">

…where color is a hex variable. However it remains grey. From what I can find online, it suggests that what I’m attempting to do is impossible, but I refuse to believe that the colour of the header can only be defined in the SASS code, and there must be a workaround - however I can’t seem to find said workaround.

Any help would be greatly appreciated, thank you in advance!