I am using Angular-7 for my web application. In the project, I applied sweetalert2.
client.component.ts
import { Component, OnInit, ElementRef, NgZone, ViewChild } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ApiService } from '../../shared/services/api.service';
import { TokenService } from '../../shared/services/token.service';
import { Router } from '@angular/router';
import { SnotifyService } from 'ng-snotify';
import swal from 'sweetalert2';
import { FormControl } from "@angular/forms";
import { MapsAPILoader } from '@agm/core';
onSubmit(){
this.notify.clear();
var header = {
'Content-Type': 'application/json'
}
return this.api.post('clientquotelanding', this.form, header).subscribe(
response => {
swal.fire(
'Congratulations!',
'Your Quote have been successfully received. You will hear from us shortly through the provided email. Thank you!',
'success'
)
},
error => this.errorHandle(error),
this.router.navigateByUrl('/landing')
);
}
The issue I have is that when I clicked on submit button, the page redirects to landing page before the sweetalert2 message pops up. How do I resolve this?