James Fallon
James Fallon

Reputation: 164

Angular 6 : alertify is not defined

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 .

Upvotes: 0

Views: 1670

Answers (1)

obaylis
obaylis

Reputation: 3034

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

Upvotes: 1

Related Questions