Angular 6 : alertify is not defined

1.6k Views Asked by At

I am getting an error saying "alert is not defined" from the "alertify" package.

This is part of my code.

alertifyservice:

    import { Injectable } from '@angular/core';

declare let alertify: any;

@Injectable({
  providedIn: 'root'
})
export class AlertifyService {
  constructor() {}

  confirm(message: string, okCallback: () => any) {
    alertify.confirm(message, function(e) {
      if (e) {
        okCallback();
      } else {
      }
    });
  }
  success(message: string) {
    alertify.success(message);
  }

angular.json:

enter image description here

Note: I've already added alertify service in app module .

1

There are 1 best solutions below

0
obaylis On

By the look of it you have only added the stylesheets. You are missing the javascript for alertifyjs.

Make sure you have added

"./node_modules/alertifyjs/build/alertify.min.js"

to your scripts array in angular.json