I am struggling to extract a value from a Map and use it as the background color of a div element, but I can't seem to get it right. My syntax seems off. What mistake am I making?
<div [style.background-color]="bgcolor" width="50px" height="50px"> Hello Green</div>
<div [style.background-color]="bgcolors['a']" width="50px" height="50px"> Hello Red</div>
Within my component, this is what I have:
bgcolor= "green";
bgcolors: Map<string,string>;
bgcolors = new Map<string,string>();
bgcolors.set("a", "red");
Check out this jsfiddle link. The first one works while the second one does not.