angular 5 上的 Alertifyjs 确认方法失败
Alertifyjs on angular 5 confirm method fails
在我的项目上尝试实施 alertifyjs 时,我在尝试 execute/implement 确认方法时遇到了一条奇怪的错误消息:这是我的服务实施:
import { Injectable } from '@angular/core';
declare let alertify: any;
alertify.defaults = {
// notifier defaults
notifier: {
position: 'top-right'
},
};
@Injectable()
export class AlertifyService {
constructor() { }
confirm(message: string, okCallback: () => any) {
alertify.confirm(message, function(e) {
if (e) {
okCallback();
}
});
}
success(message: string) {
alertify.success(message, 3);
}
}
当我调用成功、错误或警告方法时,它工作得很好,但当我尝试调用确认方法时,它破坏了应用程序:
hello() {
this.alertify.confirm('Anyone there ?', () => {console.log('hey there ...'); });
}
错误如下所示:
使用 alertifyjs 版本 1.11.1 ... 谢谢。
将默认设置为:
参考---->alertify js demo
alertify.defaults = {
// dialogs defaults
// language resources
glossary:{
// dialogs default title
title:'AlertifyJS',
// ok button text
ok: 'OK',
// cancel button text
cancel: 'Cancel'
},
// theme settings
theme:{
// class name attached to prompt dialog input textbox.
input:'ajs-input',
// class name attached to ok button
ok:'ajs-ok',
// class name attached to cancel button
cancel:'ajs-cancel'
}
};
在我的项目上尝试实施 alertifyjs 时,我在尝试 execute/implement 确认方法时遇到了一条奇怪的错误消息:这是我的服务实施:
import { Injectable } from '@angular/core';
declare let alertify: any;
alertify.defaults = {
// notifier defaults
notifier: {
position: 'top-right'
},
};
@Injectable()
export class AlertifyService {
constructor() { }
confirm(message: string, okCallback: () => any) {
alertify.confirm(message, function(e) {
if (e) {
okCallback();
}
});
}
success(message: string) {
alertify.success(message, 3);
}
}
当我调用成功、错误或警告方法时,它工作得很好,但当我尝试调用确认方法时,它破坏了应用程序:
hello() {
this.alertify.confirm('Anyone there ?', () => {console.log('hey there ...'); });
}
错误如下所示:
使用 alertifyjs 版本 1.11.1 ... 谢谢。
将默认设置为:
参考---->alertify js demo
alertify.defaults = {
// dialogs defaults
// language resources
glossary:{
// dialogs default title
title:'AlertifyJS',
// ok button text
ok: 'OK',
// cancel button text
cancel: 'Cancel'
},
// theme settings
theme:{
// class name attached to prompt dialog input textbox.
input:'ajs-input',
// class name attached to ok button
ok:'ajs-ok',
// class name attached to cancel button
cancel:'ajs-cancel'
}
};