如何在Angular2中使用离子2中的SweetAlert?

时间:2017-02-24 12:32:51

标签: angular ionic2 alert

SwaI位(   “干得好!',   '您点击了按钮!',   '成功' )

我想在我的离子应用程序中使用这种类型的swal警报使用角度2可以任何人指导吗?

1 个答案:

答案 0 :(得分:2)

有一个可用于角度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;
  }

当sweetalert2.min.css加载时,这将有效。

编辑9月:2017

截至2017年8月已弃用

您应该使用https://github.com/toverux/ngsweetalert2https://www.npmjs.com/package/sweetalert2