Ionic 4 Add dynamic class to ion-content

I’m trying to use a dynamic class in ion-content to change the color of the screen when the user performs a certain action.
my basic code for this is
<ion-content [class]='myDynamicClass'>
and in the .ts file, I change the class according to my requirement.

But a class called hydrated gets replaced by this process and the view goes invisible. Now I can copy the css attributes of hydrated and have it in my class or also make the myDynamicClass variable also have a hydrated section appended to it. My question here is:

Is there any other class apart from hydrated that might appear in ion-content when ionic does its stuff in the background?


Solved it with ngClass…
You forget the smallest of things when you’re sleep deprived lol.

1 Like

@pjoriginal pardon my ignorance but can you post your code to show how you change the class dynamically? Do you do it in the YourPage.TS file?

I just changed <ion-content [class]='myDynamicClass'> to <ion-content [ngClass]='myDynamicClass'>

the myDynamicClass is a string in the .ts file which is toggled through methods.