1

I want to change the direction of the side menu automatically when i change the language (rtl and ltr) i tried this code in the page app.html

<ion-menu [side]="isRtl?'right':'left'" [content]="content">

How can i change the value of 'isRtl' from another page or example "home.ts" ?

'isRtl' is declared in 'app.component.ts' any help guys ?

Fray
  • 250
  • 2
  • 5
  • 16

1 Answers1

3

Use event emitor for cross component to transfer data between components

//Home component.ts
import { Events } from 'ionic-angular';  
   constructor(public events: Events) {
      directioChange(user) {
            this.events.publish('directiochanged', 'true');
      }
   }


//App.component.ts
constructor(public events: Events) {
     events.subscribe('directiochanged', (direction) => { 
           this.isRtl = direction;console.log(direction);
     });
}

not only from home component, you can set from anywhere in you project

Raja Mohamed
  • 1,026
  • 9
  • 22