我从“ 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:
注意:我已经在应用模块中添加了Alertify服务。
答案 0 :(得分:0)
从外观上看,您仅添加了样式表。您缺少用于alertifyjs的JavaScript。
确保已添加
"./node_modules/alertifyjs/build/alertify.min.js"
到angular.json中的脚本数组