#alertifyjs basic problem at integration

5 messages · Page 1 of 1 (latest)

wooden lotus
#

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { select, Store } from '@ngrx/store';
import { setAPIStatus } from 'src/app/shared/store/app.action';
import { selectAppState } from 'src/app/shared/store/app.selector';
import { Appstate } from 'src/app/shared/store/appstate';
import { Books, stats } from '../store/crud';
import { invokeSaveNewBookAPI } from '../store/crud.action';
import * as alertifyjs from 'alertifyjs';



@Component({
  selector: 'app-add',
  templateUrl: './add.component.html',
  styleUrls: ['./add.component.css'],
})
export class AddComponent implements OnInit {
  constructor(
    private store: Store,
    private appStore: Store<Appstate>,
    private router: Router
  ) {}

  bookForm: Books = {
    id: 0,  
    name: '',
    status: stats.Available,
  };

  ngOnInit(): void {}

  save() {
    this.store.dispatch(invokeSaveNewBookAPI({ newBook: this.bookForm }));
    let apiStatus$ = this.appStore.pipe(select(selectAppState));
    apiStatus$.subscribe((apState) => {
      if (apState.apiStatus == 'success') {
        // const alertifyjs = require('alertifyjs');
         alertifyjs.succes("Salvat cu succes")
        this.appStore.dispatch(
          setAPIStatus({ apiStatus: { apiResponseMessage: '', apiStatus: '' } })
        );
         this.router.navigate(['/']);
        
      }
    });
  }
}


#

I only found this solution but i do get another error when i replace the import with const

#

I followed this steps to install correctly alertifyjs