2017-09-21 7 views
-1

ユーザーログイン後にsidemenuを変更して、名前とそのsidemenuを表示できるようにしたい。私はこのコードが理解できると思います。あなたはIonic 2 - ユーザーログイン後のサイドメニューの変更

this.storage.set('vAuthToken', vAuthToken);

にログインするとき

rootPage: any = SlidesPage;  
    if(SlidesPage){ 
       this.pages = [ 
       { title: 'Welcome', component: SlidesPage }, 
       { title: 'Home', component: HomePage }, 
       { title: 'House & Lot', component: HousePage }, 
       { title: 'Condominium', component: CondoPage }, 
       { title: 'Apartment', component: ApartmentPage }, 
       { title: 'Hotel', component: HotelPage } 
       ]; 
      } else { 
       this.pages = [ 
       { title: 'Dashboard', component: SellerPage }, 
       { title: 'My Properties', component: SellerPage }, 
       { title: 'Properties', component: HomePage }, 
       { title: 'House & Lot', component: HousePage }, 
       { title: 'Condominium', component: CondoPage }, 
       { title: 'Apartment', component: ApartmentPage }, 
       { title: 'Hotel', component: HotelPage } 
       ]; 
      } 

答えて

0

はapp.component.ts

initializeApp() { 
this.platform.ready().then(() => { 
    this.storage.get('vAuthToken').then((val) => { 
    if (val == null) { 
    this.menuCtrl.enable(false, 'authenticated'); 
    this.menuCtrl.enable(true, 'unauthenticated'); 
    } 
    else { 
    this.menuCtrl.enable(true, 'authenticated'); 
    this.menuCtrl.enable(false, 'unauthenticated'); 
    } 
    }); 
}); 
} 
this.authenticated = [ 
      { title: 'Welcome', component: SlidesPage }, 
      { title: 'Home', component: HomePage }, 
      { title: 'House & Lot', component: HousePage }, 
      { title: 'Condominium', component: CondoPage }, 
      { title: 'Apartment', component: ApartmentPage }, 
      { title: 'Hotel', component: HotelPage } 
      ]; 
      this.unauthenticated = [ 
      { title: 'Dashboard', component: SellerPage }, 
      { title: 'My Properties', component: SellerPage }, 
      { title: 'Properties', component: HomePage }, 
      { title: 'House & Lot', component: HousePage }, 
      { title: 'Condominium', component: CondoPage }, 
      { title: 'Apartment', component: ApartmentPage }, 
      { title: 'Hotel', component: HotelPage } 
      ]; 

に)、その後(intializaAppにそれを確認のlocalStorageにあなたにこの意志は役に立ち希望のトークンを設定し!

+0

OK TYで、私はこれをしようと、新しいプロジェクトを開始今のところ私はUIを使って作業しています。 –

0

イオン会議アプリケーションは、イベントシステム、ローカルトークンストレージ、およびページ付きアレイを使用して、これを行う方法を正確に示しています。また、Jaydeep Katariaのコードのラインに沿って。

ちょうど私が機能に作業する際に、イオン会議テンプレート(もちろん最新のイオンバージョン)

よろしく、

トム

関連する問題