Skip to content

Commit

Permalink
fetch basehref at runtime (instead of hardcoding at buildtime)
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitnarechania committed Sep 18, 2024
1 parent 50f1a2f commit 09685c3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/applications/home/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { Location } from '@angular/common';

@Component({
selector: "home",
Expand All @@ -9,14 +10,14 @@ import { Router } from "@angular/router";
})
export class HomeComponent implements OnInit {

constructor(private router: Router) {
constructor(private router: Router, private location: Location) {
}

ngOnInit(): void { }

navigateToRoute(route:string){
const url = `${window.location.origin}/showcase/#/${route}`;
const baseHref = this.location.prepareExternalUrl('');
const url = `${window.location.origin}${baseHref}#/${route}`;
window.open(url, '_blank');
// this.router.navigateByUrl(route, '_blank');
}
}

0 comments on commit 09685c3

Please sign in to comment.