how to set direction based on language in angular code example
Example: how to set direction based on language in angular
import { Component } from '@angular/core';
import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
textDir: string = 'ltr';
constructor(private translate: TranslateService) {
this.translate.onLangChange.subscribe((event: LangChangeEvent) =>
{
if(event.lang == 'ar')
{
this.textDir = 'rtl';
}
else
{
this.textDir = 'ltr';
}
});
}
}