This is my html file
<button (click)="pay()">Add to Cart</button>
This is my ts file
pay(){
Swal.fire(
`Congratulations!!🤩`,
`<h3>The item has been added to the cart!!<h3>`,
'success');
}
So, when I click on the OK(which in here is success), I want user to redirect to the Cart Page of the site. How do I add a link?
Just make use of JavaScript promises. Put the then method after swal function. We do not need to use timer features. For example:
swal({
title: 'Request Delivered',
text: 'You can continue with your search.',
type: 'success'
}).then(function() {
window.location = "redirectURL";
})
Thank you
pay(){
Swal.fire(
`Congratulations!!🤩`,
`<h3>The item has been added to the cart!!<h3>`,
'success').then(() => {
this.router.navigate(['/yourCartPage']);
})
}