角度6:未定义alertify

时间:2018-10-22 16:57:29

标签: angular6 alertify

我从“ alertify”包中​​收到一条错误消息,提示“未定义警报”。

这是我的代码的一部分。

alertifyservice:

    import { Injectable } from '@angular/core';

declare let alertify: any;

@Injectable({
  providedIn: 'root'
})
export class AlertifyService {
  constructor() {}

  confirm(message: string, okCallback: () => any) {
    alertify.confirm(message, function(e) {
      if (e) {
        okCallback();
      } else {
      }
    });
  }
  success(message: string) {
    alertify.success(message);
  }

angular.json:

enter image description here

注意:我已经在应用模块中添加了Alertify服务。

1 个答案:

答案 0 :(得分:0)

从外观上看,您仅添加了样式表。您缺少用于alertifyjs的JavaScript。

确保已添加

"./node_modules/alertifyjs/build/alertify.min.js"

到angular.json中的脚本数组