Applying ngStyle to all p tags within an html page

259 Views Asked by At

I am currently writing code for an Angular project that changes color dynamically based on the user selecting a theme. When a theme is selected it grabs from an api the hex code for the desired color to theme the app in, which for this I want to apply the theme color to all text. Currently I can apply it individually to each p tag through ngStyle by typing it as <p [ngStyle]="{'color': api.color}"> , though I want to be able to apply it to all instance of the p tag without repeating it for each of them.

1

There are 1 best solutions below

0
Vincent Lim On

You can add Angular Global CSS file to apply global style. Here are the references:

  1. Angular Global CSS styles
  2. angular-cli how to add global styles?