angularalertifyjs

Alertifyjs on angular 5 confirm method fails


While trying to implement alertifyjs on my project, I've bumped into a weird error message when trying to execute/implement the confirm method: Here's my service implementation:

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

When I call the successfull, error or warning methods, it works perfectly, but when trying to call the confirm one, it breaks the application:

  hello() {
    this.alertify.confirm('Anyone there ?', () => {console.log('hey there ...'); });
  }

Error shown below: enter image description here

Using alertifyjs version 1.11.1 ... thanks.


Solution

  • Set Defaults As:

    Reference ----> 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'
            }
        };