In my app I'm going to add or remove a class based on the device orientation. So if the app is portrait things would remain as it is. If it's landscape, then a class should get added.
I know I can easily do this with [class.ClassName] -
<div class="parentclass" [class.landscapeClass]="makeTrue">
<span></span>
</div>
But the problem is I will have to repeat this change in several templates.
How can I can easily add and remove a class (landscapeClass
in my example) wherever another class (parentclass
) is used? And remove it when the app is portrait.
I'm getting the orientation of the app using the cordova screen orientation plugin.
I'm using Angular2 RC4 and I'm looking for solution without having to use Jquery.
EDIT: The reason I'm trying to find a solution like this is because using media queries messes up my UI when the keyboard comes up on Android. I'm aware of the work around using aspect-ratio but it's not a 100% reliable solution.