2017-09-26 104 views
0

我在進行測試時點擊按鈕時出現問題。登錄後無法點擊離子菜單按鈕

場景:

在登錄時 - >用戶需要測試並提交 - >用戶被重定向主頁上。但在我的主頁,我不能在「菜單按鈕」,點擊我的Login.ts

if (this.checker == "false" || this.checker == null) { 
    this.navCtrl.setRoot(LearnertestPage); 
} else { 
    this.navCtrl.setRoot(SplashscreenPage); 
} 

我test.ts

在警報控制器

,我有這個

{ 
    text: 'Yes', 
    handler: data => { 
     this.learningStyles.push(
     [ 
     {style: "Auditory", value: AudioTotal}, 
     {style: "Logical", value: LogicalTotal}, 
     {style: "Physical", value: PhysicalTotal}, 
     {style: "Social", value: SocialTotal}, 
     {style: "Solitary", value: SolitaryTotal}, 
     {style: "Visual", value: VisualTotal}, 
     {style: "Verbal", value: VerbalTotal}] 
    ); 
     this.userChecker.update(this.currentUser, { Checker: 'true' }); 
     this.navCtrl.setRoot(SplashscreenPage); 
    } 
    } 

而且最後我的閃屏或家庭上:

HTML:

<ion-menu [content]="content"> 
<ion-content> 
<ion-item style="background-color:#00aced"> 
    <img src="./assets/img/adapt.png" height="100px" width="350px"/> 
</ion-item> 
<ion-list> 

    <button ion-item *ngFor="let p of pages" (click)="openPage(p)"> 
    <ion-icon name="{{p.icon}}"></ion-icon>&nbsp;{{p.title}} 
    </button> 

    <button ion-item (click)="doConfirm()"> 
    <ion-icon name="log-out"></ion-icon>&nbsp;Logout 
    </button> 

</ion-list> 

在splashscreen.ts

@ViewChild(Nav) nav: Nav; 
    selectedItem: any; 
    rootPage: any = ListPage; 
    selectedTheme:String; 
    icons: string[]; 
    pages: Array<{ title: string, component: any, icon: string }> 

constructor(){ 

// used for an example of ngFor and navigation 
    this.pages = [ 
     { title: 'Home', component: SplashscreenPage, icon: this.icons[0], }, 
     { title: 'Earth Science', component: LessonPage, icon: this.icons[1] }, 
     { title: 'Progress', component: ProfilePage, icon: this.icons[2] } 

    ]; 
} 


openPage(page) { 
// Reset the content nav to have just this page 
// we wouldn't want the back button to show in this scenario 
this.nav.setRoot(page.component); } 

我似乎無法點擊此按鈕。嗯。我究竟做錯了什麼? I can't seem to click on this button.

回答

0

嘗試自定義切換菜單。將toggleMenu方法添加到(單擊)菜單按鈕

import { Component } from '@angular/core'; 
    import { MenuController } from 'ionic-angular'; 

    @Component({...}) 
    export class MyPage { 

    constructor(public menuCtrl: MenuController) { 

    } 


    toggleMenu() { 
     this.menuCtrl.toggle(); 
    } 

    } 
+0

仍然無法解決我的問題 – AngularNewbie