I am trying to include sweetalert2 in my Angular project, but it gives compile time error. The error /src/app/pages/signup/signup.component.ts:29:16-25 - Error: export 'default' (imported as 'Swal') was not found in 'sweetalert2' (module has no exports)
1.install sweetalert2 2.import on component .ts file (import Swal from 'sweetalert2') 3.call by using Swal.fire()
/src/app/pages/signup/signup.component.ts:29:16-25 - Error: export 'default' (imported as 'Swal') was not found in 'sweetalert2' (module has no exports)
anyone having solution?
I had this exact same error, problem was that I was exporting the component as:
const Component = () => { Swal.fire({ //configs... })
export default Component;
I deleted that last line and changed to:
export const Component = () => { Swal.fire({ //configs... })
And everything started to work again.
"styles": [
"../node_modules/sweetalert2/dist/sweetalert2.css"
],
"scripts": [
"../node_modules/sweetalert2/dist/sweetalert2.js",
],
import swal from "sweetalert2";
swal({
type: 'success',
title: 'your message',
showConfirmButton: false,
timer: 1500
});