Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 is to determine the text direction depending on the selected language

    this.translate.onLangChange.subscribe((event: LangChangeEvent) =>
    {
      if(event.lang == 'ar')
      {
        this.textDir = 'rtl';
      } 
      else
      {
        this.textDir = 'ltr';
      }
    });
  }

  

}
Comment

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 is to determine the text direction depending on the selected language

    this.translate.onLangChange.subscribe((event: LangChangeEvent) =>
    {
      if(event.lang == 'ar')
      {
        this.textDir = 'rtl';
      } 
      else
      {
        this.textDir = 'ltr';
      }
    });
  }

  

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: sort datatable c# 
Javascript :: find only vowels in string Javascript 
Javascript :: django restframework jquery post 
Javascript :: mongoose wont update value in array 
Javascript :: onpress react native datepicker stackver flow 
Javascript :: scriptmanager call javascript function 
Javascript :: Pure JavaScript Send POST NO JQUERY 
Javascript :: boxcolliion code javascript 
Javascript :: theme ui currentcolor 
Javascript :: scratch addons 
Javascript :: express rate limit redis 
Javascript :: how to delete an item on click in js 
Javascript :: styleurls component angular node_modules 
Javascript :: how to send authorization in header of HTTP GET using ajax 
Javascript :: Function to convert an Array to an Associative array 
Javascript :: progrmatically change audio src 
Javascript :: att asm jmp 
Javascript :: conflict paypal api javascript with user agent Mozilla/5.0 Google 
Javascript :: var test 
Javascript :: javascript Bingo add called number to a list 
Javascript :: how to store textbox data while typing for chrome extension 
Javascript :: js replace blogger thumb 
Javascript :: useEffectOnce 
Javascript :: Compare unequality of two operands. 
Javascript :: what is code.jquery integrity crossorigin 
Javascript :: react function called last state 
Javascript :: firefox extension make ajax request 
Javascript :: coment executer des touche de clavier avec du js 
Javascript :: mindfusion calendar 
Javascript :: onclick display array value javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =