ion-menu dynamically change direction

41 views Asked by At

I am using ionic 6. I have ion-menu that don't change his direction with the app direction. I changed the direction of the app with document.documentElement.setAttribute('dir', 'rtl') and the ion-menu side is "start", but he still open up like rtl.

1

There are 1 answers

3
Najam Us Saqib On

You can do something like this:

import { DOCUMENT } from '@angular/common';

class YourComponent{

   constructor(
     @Inject(DOCUMENT) private document: Document
   ){}

   onDirectionChange(){
     if (yourCondition)
       this.document.documentElement.dir = 'rtl';
     else{
       this.document.documentElement.dir = 'ltr';
     }
   }

}

This will change whole app's direction including ion-menu.