...

/

The Built-in `NgStyle` Directive

The Built-in `NgStyle` Directive

Let’s learn about `NgStyle`, a built-in attribute directive.

We'll cover the following...

In the previous lesson, we learned how to change the styling of elements using dynamically applied CSS classes. But, is that all we need in the case of dynamic styling?

Let’s think about specific situations when we need to apply precise styling, like a calculated color or a particular size. We are working with values that are calculated at runtime and can’t be predicted. So, we can’t prepare CSS classes with the required styling beforehand.

However, we need to be careful with this directive. Styles applied using NgStyle are ...