Search code examples
angularsweetalertsweetalert2

How to use Swal in Angular project?


Well, I have an angular project and want to use swal2 on it, but i don't know how to integrate it.

Help please.


Solution

  • You need to install it with the command,

    npm install --save sweetalert
    

    and then in the component,

    import swal from 'sweetalert';
    

    use it as,

     swal({
          content: component.location.nativeElement
        }).then(() => {
          component.destroy();
        });
    

    STACKBLITZ DEMO