angularalertifyjs

Alertify Error "ReferenceError: alertify is not defined " in Angular 6


I try to use alertify.js in my project .So I followed this material https://signl.uk/tutorial/index/notify-service-with-angular-5. But I got a error ReferenceError: alertify is not defined when click button in my application.

alertifyjs css and js files I add into angular.json file.

![enter image description here

alertify.service.ts

![enter image description here

Help me for identify my mistake.

Edit

I import AlertifyService in component.ts file as private alertify: AlertifyService and In app module import { AlertifyService } from './services/alertify.service'; and added AlertifyService in provider as providers: [AlertifyService]

I use alertify in my login component

login.component.ts

login(){
let email = this.loginForm.get("email").value;
let password = this.loginForm.get("password").value;
this.loading = true;
this.authService.login(email, password).subscribe(response => {

  this.alertify.success('Successfully Login');

  this.loading = false;

  // Save data to sessionStorage
  localStorage.setItem('isLoggedIn', "true");
  localStorage.setItem('currentUserID', response.user.uid);
  this.router.navigate(['/dashboard'])
}, error => {
  this.loading = false;
 });
}

Solution

    1. Restart server.

    2. If get error like

      no such file or directory, open 'D:\testProject\node_modules\alertifyjs\build\alertify.min.js'

    then Change

    "../node_modules/bootstrap/dist/css/bootstrap.min.css", "../node_modules/alertifyjs/build/css/alertify.min.css", "../node_modules/alertifyjs/build/css/themes/bootstrap.min.css",

    to

    "./node_modules/bootstrap/dist/css/bootstrap.min.css",
    "./node_modules/alertifyjs/build/css/alertify.min.css",
    "./node_modules/alertifyjs/build/css/themes/bootstrap.min.css",