I have an ionic application which supports multiple languages. How can I do Change Direction dynamically?
Thanks for the help.
I have an ionic application which supports multiple languages. How can I do Change Direction dynamically?
Thanks for the help.
Maby that helpfull
<ion-tabs mode="ios" dir="{{currentLanguage == 'en'?'ltr':'rtl'}}">
or
<ion-tabs mode="ios" [dir]="currentLanguage == 'en'?'ltr':'rtl'">
Can you try below:
import { Component, Inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { DOCUMENT } from '@angular/common';
constructor(
@Inject(DOCUMENT) private document: Document,
private translate: TranslateService) {
this.lang = localStorage.getItem('LANG');
}
languageChanged() {
localStorage.setItem('LANG', this.lang);
this.translate.setDefaultLang(this.lang);
if (this.lang === 'iw')
this.document.documentElement.dir = 'rtl';
else
this.document.documentElement.dir = 'ltr';
}