Devang Mistry
Devang Mistry

Reputation: 593

How to use SweetAlert in ionic 2 with Angular2?

swal( 'Good job!', 'You clicked the button!', 'success' )

I want to use this type of swal alert in my ionic app using angular 2 Can anyone guide?

Upvotes: 0

Views: 3776

Answers (1)

Parth Ghiya
Parth Ghiya

Reputation: 6949

There's a sweet alert module available for angular 2

https://github.com/seiyria/ng2-sweetalert2

import { SweetAlertService } from 'ng2-sweetalert2';

@Component({
  providers: [SweetAlertService]
})
export class MyComponent {

  static get parameters() {
    return [[SweetAlertService]];
  }

  constructor(swal) {
    this.swalService = swal;
  }

This will work when sweetalert2.min.css loaded up.

EDIT Sept:2017

This is DEPRECATED as of August 2017

You should use https://github.com/toverux/ngsweetalert2 or https://www.npmjs.com/package/sweetalert2

Upvotes: 2

Related Questions