Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error #2

Open
b-mi opened this issue Oct 10, 2017 · 8 comments
Open

Error #2

b-mi opened this issue Oct 10, 2017 · 8 comments
Labels

Comments

@b-mi
Copy link

b-mi commented Oct 10, 2017

Installed angular wrapper, I use angular 4, and got this error:

ERROR TypeError: myWindow.Sweetalert2 is not a function
at SweetAlertService.webpackJsonp.../../../../angular-sweetalert-service/js/service/sweetalert2.service.js.SweetAlertService.confirm (sweetalert2.service.js:25)

In component code I used

import { SweetAlertService } from 'angular-sweetalert-service';
not
import { SweetAlertService } from 'angular-sweetalert'; // this not work

Then, command from your page end with error:

        this.alertService.confirm({
            title: 'Delete account?'
          })
          .then(() => {
            this.alertService.success({
              title: 'Account deleted'
            });
          })
          .catch(() => console.log('canceled'));
@juan-manuel-alberro
Copy link
Owner

Hello @b-mi
I'll take a look, maybe a new version was released and is not backward compatible.

@tunathoni
Copy link

Hello @juan-manuel-alberro i also get an error like this, is it was resolved ? or still not yet ?

@sangwin
Copy link

sangwin commented Oct 31, 2017

+1. Not working at all

@jeffreypolk
Copy link

You need to manually include sweetalert2 for this to work.

@b-mi
Copy link
Author

b-mi commented Nov 2, 2017

@jeffreypolk - how exactly include sweetalert2 'manually '? I use instructions for install from author - but it not work. Did you try your solution on angular 4?

@jeffreypolk
Copy link

Yes using Angular4. Not sure if it's the "right" way, but I just included sweetalert2 CDN js and css references in my index.html

@sokphea-chea
Copy link

sokphea-chea commented Nov 13, 2017

I have the same problem like b-mi, and I think the problem come from webpack compile.

@PixeliGer
Copy link

@b-mi I found that 'manual installation' means installing and adding SweetAlert2 in angular.cli.json

First Install SweetAlert2 vía npm
npm install --save sweetalert2

In your angular.cli.json include the css and js files

"styles": [
        ...
        "../node_modules/sweetalert2/dist/sweetalert2.min.css",
        ...
      ],
"scripts": [
          ...
          "../node_modules/sweetalert2/dist/sweetalert2.min.js",
          ...
      ],

Now run ng-serve again, and angular-sweetalert-service will work without problems.

###Note
Im still with the webpack warning about compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants