首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在angular 5上的Alertifyjs确认方法失败

在angular 5上的Alertifyjs确认方法失败
EN

Stack Overflow用户
提问于 2018-08-25 14:00:43
回答 1查看 1.5K关注 0票数 1

当我试图在我的项目上实现alertifyjs时,我在尝试执行/实现confirm方法时遇到了一个奇怪的错误消息:以下是我的服务实现:

代码语言:javascript
复制
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);
}
}

当我调用successfull、error或warning方法时,它工作得很好,但当尝试调用confirm方法时,它会中断应用程序:

代码语言:javascript
复制
  hello() {
    this.alertify.confirm('Anyone there ?', () => {console.log('hey there ...'); });
  }

错误显示如下:

使用alertifyjs版本1.11.1...谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-25 15:24:51

将默认值设置为:

参考-> alertify js demo

代码语言:javascript
复制
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'
        }
    };
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52014474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档