I am using Material 2 to add md-raised-button. I want to apply this directive only if certain condition becomes true.
For example:
<
As at 18th Jan 2019,
This is how I added a directive conditionally in Angular 5 and above. I needed to change the color of the component based on darkMode. If the page was in dark mode or not.
This worked for me:
I hope this helps someone.
EDIT
This changes the value of an attribute (color) based on a condition. It just happens that the color is defined using a directive. So anyone reading this please do not get confused, this is not applying a directive conditionally (ie. which means adding or removing a directive to the dom based on a condition)