Angular project using NgRx pattern to manage state of a system

projects-list.component.ts 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. import { MsgState } from 'src/app/ngrx/msg.state';
  2. import { Store } from '@ngrx/store';
  3. import { Router } from '@angular/router';
  4. import { Project } from './../../../../shared/models/project/project.model';
  5. import { ProjectState } from './../../../../ngrx/projects/project.state';
  6. import { Component, Input, OnInit } from '@angular/core';
  7. import { DeleteProjectAction } from 'src/app/ngrx/projects/projects.actions';
  8. @Component({
  9. selector: 'app-projects-list',
  10. templateUrl: './projects-list.component.html',
  11. styleUrls: ['./projects-list.component.css'],
  12. })
  13. export class ProjectsListComponent implements OnInit {
  14. constructor(
  15. private router: Router,
  16. private store: Store<{ projectReducerKey: ProjectState }>
  17. ) {}
  18. @Input() inputProjectState!: ProjectState;
  19. ngOnInit(): void {}
  20. onEditProject(project: Project) {
  21. this.router.navigate(['/project-update/' + project.id]);
  22. }
  23. onProjectDelete(project: Project) {
  24. if(window.confirm(MsgState.CONFIRM_DEL)){
  25. this.store.dispatch(new DeleteProjectAction(project));
  26. }
  27. }
  28. }

Powered by TurnKey Linux.