[英]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
我认为您应该使用this.navCtrl.setRoot(HomePage);
而不是this.navCtrl.push(HomePage);
还有另一种方法可以做到这一点。 在HomePage.ts
执行以下操作
import { ViewController } from 'ionic-angular';
constructor(public viewCtrl: ViewController) {}
ionViewWillEnter() {
this.viewCtrl.showBackButton(false);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.