1

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.

Mike Gmez
  • 111
  • 3
  • 18
  • 1
    Looks like you didn't provide proper defaults, i.e. `alertify.defaults.glossary.ok` and `alertify.defaults.theme.ok` – yurzui Aug 25 '18 at 06:30

1 Answers1

1

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'
        }
    };
Akj
  • 7,038
  • 3
  • 28
  • 40