From 15c23fad0f8d781ad3b357a2c234f1cca8d73c6e Mon Sep 17 00:00:00 2001 From: Natalie Hergesheimer Date: Thu, 9 Jan 2025 11:28:47 -0700 Subject: [PATCH] Swapped to using activatedRoute to grab url --- .../crr-results-page.component.ts | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/CSETWebNg/src/app/assessment/results/crr/crr-results-page/crr-results-page.component.ts b/CSETWebNg/src/app/assessment/results/crr/crr-results-page/crr-results-page.component.ts index 3f4c0eabc8..554b77a4ae 100644 --- a/CSETWebNg/src/app/assessment/results/crr/crr-results-page/crr-results-page.component.ts +++ b/CSETWebNg/src/app/assessment/results/crr/crr-results-page/crr-results-page.component.ts @@ -22,10 +22,9 @@ // //////////////////////////////// import { Component, OnInit } from '@angular/core'; -import { NavigationEnd, Router } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { ConfigService } from '../../../../services/config.service'; import { MaturityService } from '../../../../services/maturity.service'; -import { filter } from 'rxjs/operators'; /** @@ -42,7 +41,7 @@ export class CrrResultsPage implements OnInit { public domain: any; public loaded = false; - public pageName = ""; + public pageName: string = ""; public domainAbbrev = ""; public domainName; @@ -57,18 +56,17 @@ export class CrrResultsPage implements OnInit { constructor( private maturitySvc: MaturityService, public configSvc: ConfigService, - private router: Router + public activatedRoute: ActivatedRoute ) { - this.router.events.pipe( - filter(event => event instanceof NavigationEnd) - ).subscribe((e: any) => { - var url: string = e.url; - var slash = url.lastIndexOf('/'); - this.pageName = url.substr(slash + 1); - this.domainAbbrev = this.pageName.substr(this.pageName.indexOf('crr-domain-') + 11).toUpperCase(); - }); + this.manualNav(); + } + /** + * We are reusing crr results component for multiple routes and must handle routing manually. + */ + manualNav(): void { + this.pageName = this.activatedRoute.snapshot.url.join('/'); + this.domainAbbrev = this.pageName.substring(this.pageName.indexOf('crr-domain-') + 11).toUpperCase(); } - /** *