Hello,
I’m trying to change the Menu side dynamically on once user changes the language.
For RTL languages menu needs to be on the right, by default the it’s set on left.
I subscribe to a event when the language changes:
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
if (event.lang == 'ar' || event.lang == 'fa') {
this.platform.setDir('ltr', false);
this.platform.setDir('rtl', true);
this.menuSide = "right";
} else {
this.platform.setDir('rtl', false);
this.platform.setDir('ltr', true);
this.menuSide = "left";
}
});
In the template:
<ion-menu [content]="content" side="{{ menuSide }}" >
...
However, even though the this.menuSide
changes in the controller, it won’t work as expected.
I’ve tried using MenuController as well, that didn’t work too:
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
if (event.lang == 'ar' || event.lang == 'fa') {
this.platform.setDir('ltr', false);
this.platform.setDir('rtl', true);
let menu: Menu = this.menuCtrl.getMenus()[0];
this.menuCtrl._unregister(menu);
menu.side = 'right';
this.menuCtrl._register(menu);
} else {
this.platform.setDir('rtl', false);
this.platform.setDir('ltr', true);
}
});
Any idea how I should get this to work ?