简体   繁体   中英

when login from ionic app to dashboard the menu button showing as a back button

 import { Component} from '@angular/core'; import { NavController } from 'ionic-angular'; import { HomePage } from '../../pages/dashboard/home'; import { Signup } from '../../commen/signup/signup'; import { Forgot } from '../../commen/forgot/forgot'; import { NgForm } from '@angular/forms'; import { AuthService } from '../../services/auth.service' import { ToastController } from 'ionic-angular'; @Component({ selector: 'page-Login', templateUrl: 'login.html', providers: [AuthService] }) export class Login { forgot:any; spinnerLoad: boolean = false; msg:any; constructor(public navCtrl: NavController,private authservice: AuthService,public toastCtrl: ToastController) { this.forgot=Forgot; } Submitlogin(value: any) { if(value.email){ this.spinnerLoad = true; let email = value.email; let pass = value.password; this.authservice.login(email, pass).subscribe((result) => { this.spinnerLoad = false; if (result) if (result.status) { localStorage.setItem('userData', JSON.stringify(result.data)); this.navCtrl.push(HomePage); } else { const toast = this.toastCtrl.create({ message: 'Invalid credentials', duration: 3000, position: 'bottom' }); toast.present(); this.spinnerLoad = false; } }, error => { this.spinnerLoad = true; }); } } onSignup() { this.navCtrl.push(Signup); } facebookLogin(){ // alert('hello') // window.location.href = 'http://d4v.nextfellow.com/login/facebook'; } } 
 <form ngsubmit="formvalue()"> <ionic-input type="text" placeholder="email example"></ionic-input> <ionic-input type="text" placeholder="password"></ionic-input> <ion-col> <button ion-button [disabled]="!loginForm.form.valid" type="submit" block>Login</button> </ion-col> </form 
html is my dummy code once i validate form and route to dashboard on the header side of the menu button showing as a back button but it should be menu right please give me the solution for this also i have dashboard component am working on ionic 3 its ....................................................

I think you should use this.navCtrl.setRoot(HomePage); instead of this.navCtrl.push(HomePage);

There is also a another way to do it. Do the following in HomePage.ts

import { ViewController } from 'ionic-angular';

constructor(public viewCtrl: ViewController) {}

ionViewWillEnter() {
  this.viewCtrl.showBackButton(false);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM