Ошибка оповещения «Ошибка ссылки: оповещение не определено» в Angular 6 - PullRequest
0 голосов
/ 20 сентября 2018

Я пытаюсь использовать alertstify.js в моем проекте. Поэтому я следовал за этим материалом https://signl.uk/tutorial/index/notify-service-with-angular-5. Но я получил ошибку ReferenceError: alertify is not defined при нажатии кнопки в моем приложении.

alerttifyjs css и jsфайлы, которые я добавляю в angular.json файл.

![enter image description here

alertstify.service.ts

![enter image description here

Помогите мне определить мою ошибку.

Редактировать

Я импортирую AlertifyService в компонент.ts файл как private alertify: AlertifyService и в модуле приложения import { AlertifyService } from './services/alertify.service'; и добавленный AlertifyService в провайдере как providers: [AlertifyService]

Я использую alerttify в своем компоненте входа

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

1 Ответ

0 голосов
/ 20 сентября 2018
  1. Перезагрузите сервер.

  2. Если получите сообщение об ошибке типа

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

затемИзменить

"../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",

на

"./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",
...