Is there a way to pass parameters from the signup page to the signupotp page successfully? I am facing an issue where the OTP on the signupotp page is not being recognized because the parameters (email and mobile) are not getting passed properly. In my backend code, for OTP verification, the params (mobile, email, otp) need to be verified but it's not working as expected. I have tried initializing the data in the signup page and passing it to the signupotp page, but it didn't work. Any suggestions on how to resolve this issue?
SIGNUP.PAGE.TS
import { Component, OnInit } from '@angular/core';
import { ApiService } from '../api.service';
import { Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { SignupotpPage } from '../signupotp/signupotp.page';
@Component({
selector: 'app-signup',
templateUrl: './signup.page.html',
styleUrls: ['./signup.page.scss'],
})
export class SignupPage implements OnInit {
Mobile: any;
Email: any;
data: any;
otp: any;
checked: any;
constructor(private api: ApiService, private router: Router, public signupotp: SignupotpPage) {}
ngOnInit() {
}
Continue(Mobile, Email){
const user = {
Mobile: Mobile,
Email: Email
}
console.log(Mobile);
console.log(Email);
this.api.SignupUser(user).subscribe(data =>{
console.log(data);
this.signupotp.initialisedata(Mobile, Email);
this.router.navigate(['signupotp']);
});
}
}
SIGNUPOTP.PAGE.TS
import { Component, OnInit } from '@angular/core';
import { ApiService } from '../api.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-signupotp',
templateUrl: './signupotp.page.html',
styleUrls: ['./signupotp.page.scss'],
})
export class SignupotpPage implements OnInit {
Mobile: any;
Email: any;
otp: any;
data: any;
constructor(private api: ApiService, private router: Router) {}
initialisedata(email, mobile)
{
console.log("HUUUU");
console.log(email, mobile);
this.Email = email;
this.Mobile = mobile;
}
ngOnInit() {
}
Confirm(otp){
const user = {
otp: otp,
mobile: this.Mobile,
email: this.Email
}
console.log(otp);
console.log("hey, how are you")
this.api.Verifysignupotp(user).subscribe(data =>{
console.log(data);
this.data = data;
if(this.data.Msg)
{
alert(this.data.Msg);
}
else
{
this.router.navigate(['/']);
}
});
}
}
Service.ts
SignupUser(user): Observable<Object>{
console.log(user);
console.log('getting the signup data from the user');
return this.http.post<Object>(`${this.base_url}/signup`, user);
}
Verifysignupotp(user): Observable<Object>{
console.log(user);
console.log('getting all listings from the server');
return this.http.post<Object>(`${this.base_url}/verifysignupotp`, user);
}