Skip to content

Commit 2eec7f7

Browse files
committed
Read frame url from enviornment file
1 parent b722914 commit 2eec7f7

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/app/go-visit/go-visit.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<iframe
22
#iframe
3-
src="http://localhost:4200/"
43
width="100%"
54
[height]="height"
65
style="border: 0"

src/app/go-visit/go-visit.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
2-
import { DomSanitizer } from '@angular/platform-browser';
2+
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
33
import { NavigationEnd, Route, Router } from '@angular/router';
44
import { Subscription } from 'rxjs';
5+
import { environment } from '@environment';
6+
7+
console.log({ environment });
58

69
@Component({
710
selector: 'app-go-visit',
@@ -14,13 +17,20 @@ export class GoVisitComponent implements AfterViewInit {
1417

1518
height = '100%';
1619
private subscription?: Subscription;
20+
private readonly frameUrl = environment.frameUrl;
1721

1822
constructor(
1923
private readonly router: Router,
2024
private readonly sanitizer: DomSanitizer
2125
) {}
2226

27+
getSourceUrl(): SafeResourceUrl {
28+
return this.sanitizer.bypassSecurityTrustResourceUrl(environment.frameUrl);
29+
}
30+
2331
ngAfterViewInit(): void {
32+
this.iframe.nativeElement.src = environment.frameUrl;
33+
// console.log(this.iframe.nativeElement.src);
2434
this.subscription = this.router.events.subscribe((event) => {
2535
if (event instanceof NavigationEnd) {
2636
this.notifyRoute();

src/environment/environment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const environment = {
2+
production: false,
3+
frameUrl: 'http://localhost:4200',
4+
};

tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"target": "ES2022",
2020
"module": "ES2022",
2121
"useDefineForClassFields": false,
22-
"lib": [
23-
"ES2022",
24-
"dom"
25-
]
22+
"lib": ["ES2022", "dom"],
23+
"paths": {
24+
"@environment": ["src/environment/environment.ts"]
25+
}
2626
},
2727
"angularCompilerOptions": {
2828
"enableI18nLegacyMessageIdFormat": false,

0 commit comments

Comments
 (0)