【发布时间】:2019-09-20 03:12:11
【问题描述】:
我将 Angular-7 用于我的 Web 应用程序。在项目中,我应用了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')
);
}
我遇到的问题是,当我单击提交按钮时,页面会在 sweetalert2 消息弹出之前重定向到登录页面。我该如何解决这个问题?
【问题讨论】:
-
订阅完成方法中
this.router.navigateByUrl('/landing')的预期行为是什么
标签: angular