、私は配管を翻訳使用して、私はStorageProviderで選択した言語(のlocalStorage)を格納子ページの値を変更した後、どのように子ページからapp.componentにアクセスするのですか?ときに我々我々のアプリケーションで
私の問題は、(app.html上、app.component)イオンのメニューでは、選択した言語に翻訳することはできません子ページの値を変更します。私のapp.html
コードを以下に示します。
app.html
<ion-menu [content]="content">
<ion-content class="smrt-dark">
<ion-list>
<button color="dark" menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)" style="height: 150%" [hidden]="!isAuthenticate(p.isAccess)">
<i class="fa fa-{{p.icon}} {{p.color}} circle-i-mn smrt-{{p.color}}" aria-hidden="true" item-start></i>
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
app.component.ts
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
pages: Array<{ title: string, component: any, icon: string, color: string, isAccess: string }>;
LANGUAGE;
constructor(...) {
console.log('main');
if (this.db._config.LANGUAGE === null){
this.storage.get('language'). then((data) => {
this.LANGUAGE = data;
this.translateService.use(this.db._config.LANGUAGE);
// used for an example of ngFor and navigation
this.pages = [
{title: translateService.instant('home'), component: HomePage, icon: 'home', color: '', isAccess: 'HOME_LIST'},
{title: translateService.instant('notes'), component: ListNotePage, icon: 'book', color: 'note', isAccess: 'NOTE_LIST'},
{title: translateService.instant('tasks'), component: ListTaskPage, icon: 'check', color: 'task', isAccess: 'ISSUE_LIST'}
];
});
}
this.initializeApp();
}
isAuthenticate(key: string){
return this.auth.isAuthenticate(key);
}
initializeApp()
{
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
app.component.ts
の属性にアクセスするための方法があれば、この解決策も私には受け入れられます。
ありがとうございます。
このソリューションはイオン性で機能しますか?私は努力していません。コンストラクタでいくつかのエラーが発生します。LoginPage:(?、[object Object]) –
イオンについては何も知らないので、わかりませんが、2番目の視点ではAngularでも機能しません。私はそれを入力していたときに私はそれを認識しませんでしたが、私はあなたが依存成分注入を介してAppコンポーネントを注入できるとは思わない、それは最も根本的なコンポーネントです。あなたは、少なくとも1つの兄弟からappコンポーネントから始めなければならないでしょう。しかし、イオンについては言うことができません。 – diopside