File

libs/employee-management/src/employee-navigation.service.ts

Index

Properties
Methods

Constructor

constructor(router: Router)
Parameters :
Name Type Optional
router Router no

Methods

add
add()
Returns : void
calculateModuleBaseRoute
calculateModuleBaseRoute(route: ActivatedRoute)
Parameters :
Name Type Optional
route ActivatedRoute no
Returns : void
edit
edit(id: number)
Parameters :
Name Type Optional
id number no
Returns : void
employeeId
employeeId(componentRoute: ActivatedRoute)
Parameters :
Name Type Optional
componentRoute ActivatedRoute no
Returns : Observable<number>
list
list()
Returns : void

Properties

Private baseRoute
baseRoute: ActivatedRoute
Type : ActivatedRoute
import { Injectable } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';

@Injectable()
export class EmployeeNavigation {
  private baseRoute: ActivatedRoute;

  constructor(private router: Router) { }

  calculateModuleBaseRoute(route: ActivatedRoute) {
    this.baseRoute = route.pathFromRoot[1];
  }

  employeeId(componentRoute: ActivatedRoute): Observable<number> {
    return componentRoute.params
      .pipe(map(params => params['id']));
  }

  list() {
    this.router.navigate(['.'], { relativeTo: this.baseRoute });
  }

  add() {
    this.router.navigate(['add'], { relativeTo: this.baseRoute });
  }

  edit(id: number) {
    this.router.navigate([id], { relativeTo: this.baseRoute });
  }
}

results matching ""

    No results matching ""