Hi everyone, I am new to ionic and creating my first app, how do I disable menu on login page,
Currently, when I do so, it hides on the entire application. See code below.
login.page.ts
import { Component, OnInit } from ‘@angular/core’;
import { Router } from ‘@angular/router’;
import { Plugins } from ‘@capacitor/core’;
import { HttpClient } from ‘@angular/common/http’;
import { HTTP } from ‘@ionic-native/http/ngx’;
import { ToastController } from ‘@ionic/angular’;
import { LoadingController } from ‘@ionic/angular’;
import { MenuController } from ‘@ionic/angular’;
const {SplashScreen} = Plugins;
@Component({
selector: ‘app-login’,
templateUrl: ‘./login.page.html’,
styleUrls: [’./login.page.scss’],
})
export class LoginPage implements OnInit {
user: any = {};
loading: any = {};
componentDidLoad(){
SplashScreen.hide();
}
constructor( private router: Router, private http: HttpClient, private toastCtrl:ToastController, public loadingController: LoadingController,private menu: MenuController) {
this.menu.enable(false, 'first');
}
async loginWithSpinner() {
this.loading = await this.loadingController.create({
message: 'Please wait...',
//duration: 2000
});
await this.loading.present();
this.login();
}
ngOnInit() {
}
async successToast() {
await this.toastCtrl.create({
message: "Welcome "+this.user['email'],
duration: 2000,
position: 'top',
cssClass: 'toast-truce',
buttons: [{
text: 'OK',
handler: () => {
console.log("ok clicked");
}
}]
}).then(res => res.present());
}
async failedToast() {
await this.toastCtrl.create({
message: "Login Failed, Check Email and Password. ",
duration: 2000,
position: 'top',
cssClass: 'toast-truce',
buttons: [{
text: 'OK',
handler: () => {
console.log("ok clicked");
}
}]
}).then(res => res.present());
}
async emptyFieldsToast() {
await this.toastCtrl.create({
message: "Notice! All Fields Are Rquired",
duration: 2000,
position: 'top',
cssClass: 'toast-truce',
buttons: [{
text: 'OK',
handler: () => {
console.log("ok clicked");
}
}]
}).then(res => res.present());
}
login(){
if(this.user['email'] == null || this.user['pass'] == null ){
this.emptyFieldsToast();
}else{
this.http.get('https://prochpetskillsinstitute.co.zm/ionic_api/index.php?email='+this.user['email']+'&pwd='+this.user['pass']).subscribe((response: any) => {
console.log(response);
if(response.success == 1){
//console.log("success");
this.successToast();
sessionStorage.setItem('email', response.email);
//this.loading.dismiss();
this.router.navigate(['home']);
}else{
//this.loading.dismiss();
this.failedToast();
}
});
}
}
navigateToSignupPage(){
this.router.navigate(['signup'])
}
goToPrivacyPage(){
this.router.navigate(['policy'])
}
goToForgotPasswordPage(){
this.router.navigate(['fogotpassword'])
}
}
1 post - 1 participant