All files / src/app/components/error error.component.ts

88.88% Statements 8/9
66.66% Branches 4/6
75% Functions 3/4
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                      53x         1x     1x 1x 1x 1x   1x                  
import { NgIf, Location } from '@angular/common';
import { HttpErrorResponse } from '@angular/common/http';
import { Component, Input, OnChanges } from '@angular/core';
import { RouterLink } from '@angular/router';
 
@Component({
  selector: 'app-error',
  imports: [NgIf, RouterLink],
  templateUrl: './error.component.html',
  styleUrl: './error.component.scss'
})
export class ErrorComponent implements OnChanges{
  @Input() error: HttpErrorResponse;
 
  ressourceName: string;
 
  constructor(private location: Location){}
 
  ngOnChanges(){
    let segment = this.error.url?.split('/')[3];
    Eif (segment !== undefined){
      Eif (segment.endsWith('s')){
        segment = segment.slice(0, -1);
      }
      this.ressourceName = segment.charAt(0).toUpperCase() + segment.slice(1);
    }
  }
 
  goBack(){
    this.location.back();
  }
 
}