【问题标题】:Alertifyjs on angular 5 confirm method fails角度 5 确认方法上的 Alertifyjs 失败
【发布时间】:2018-08-25 06:00:43
【问题描述】:

在我的项目中尝试实现 alertifyjs 时,我在尝试执行/实现确认方法时遇到了一个奇怪的错误消息:这是我的服务实现:

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.defaults.glossary.okalertify.defaults.theme.ok

标签: angular alertifyjs


【解决方案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'
        }
    };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 2018-04-17
    • 2020-01-24
    • 1970-01-01
    相关资源
    最近更新 更多