Alertifyjs на угловых 5 подтвердить метод не удается - PullRequest
0 голосов
/ 25 августа 2018

При попытке реализовать alerttifyjs в моем проекте я столкнулся со странным сообщением об ошибке при попытке выполнить / реализовать метод подтверждения: Вот моя реализация службы:

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 ...'); });
  }

Ошибка, показанная ниже: enter image description here

Использование alerttifyjs версии 1.11.1 ... спасибо.

1 Ответ

0 голосов
/ 25 августа 2018

Установить значения по умолчанию как:

Ссылка ----> alert 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'
        }
    };
...