4

私は自分のプロジェクトで alertify.js を使用しようとしていますReferenceError: alertify is not definedしかし、アプリケーションでボタンをクリックするとエラーが発生しました。

alertifyjs css および js ファイルをangular.jsonファイルに追加します。

![ここに画像の説明を入力

alertify.service.ts

![ここに画像の説明を入力

私の間違いを特定するのを手伝ってください。

編集

私はalertifyServiceをcomponent.tsファイルにインポートしprivate alertify: AlertifyService、アプリモジュール にインポートimport { AlertifyService } from './services/alertify.service';し、プロバイダーにAlertifyServiceを追加しました providers: [AlertifyService]

ログインコンポーネントでアラートを使用しています

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

3 に答える 3

3
  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",
于 2018-09-20T10:33:21.037 に答える