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.
alertify.service.ts
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;
});
}
Restart server.
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",