我尝试在我的项目中使用 alertify.js。所以我遵循了这个材料https://signl.uk/tutorial/index/notify-service-with-angular-5。但是ReferenceError: alertify is not defined
在我的应用程序中单击按钮时出现错误。
我添加到angular.json文件中的alertifyjs css 和 js文件。
alertify.service.ts
帮助我找出我的错误。
编辑
我在 component.ts 文件中将 AlertifyService 导入为private alertify: AlertifyService
和在 app 模块 import { AlertifyService } from './services/alertify.service';
中,并在提供程序中添加 AlertifyService 作为 providers: [AlertifyService]
我在我的登录组件中使用 alertify
登录组件.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;
});
}