2017-08-20 3 views
1

は、私は私が言語(RTLとLTR)を変更するとき、私はページにこのコードを試してみました 自動的にサイドメニューの向きを変更したいapp.htmlイオン3 - サイドメニューは、変更側が動的に

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

「isRtl」の値を別のページまたは例「home.ts」から変更するにはどうすればよいですか?

'isRtl'は 'app.component.ts'で宣言されています ヘルプユーザーは?

+0

isRtlを投射する関数や変数のですか? –

+0

@surajこれは 'app.component.ts'で宣言されたvarですが、isRtlの値を別のページ、たとえば "home.ts"から変更するにはどうすればいいですか? – Fray

答えて

3
ホームコンポーネントから構成

//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); 
    }); 
} 

ないだけの間でデータを転送するクロスコンポーネントの

使用イベントemitor、あなたはあなたの中にどこからでも設定でき

関連する問題