Search code examples
angularprism.jsprismjs

Angular - styles being ignored/overwritten


I'm having an issue with styles not being applied to elements. If I add style information to the component's styles parameter, or provide a CSS file in the styleUrls parameter, I get the expected results. However, inline HTML styles are not being applied. In the below example I'm trying to apply a red background to a div, but it stays white. This HTML exists as a template for an Angular Component.

<div style="background: red;">test</div>

However, if I add ngStyle="" to the element such as:

<div style="background: red;" ngStyle="">test</div>

Then Angular renders the background of the div in red.

Any ideas what is causing Angular to ignore style attributes like this?


Solution

  • I ended up upgrading all of my libraries (from Angular 4 to Angular 5) and with no code changes the style information was rendered as expected.