From 6845f9afd314e45638b709f5516c3db6484938fa Mon Sep 17 00:00:00 2001 From: eneller Date: Sun, 23 Mar 2025 20:56:05 +0100 Subject: [PATCH] fix: use ng searchparams use ng ActivatedRoute replacing window.location.search --- src/app/app.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6dbfede..1166eef 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -23,10 +23,12 @@ export class AppComponent implements OnInit { constructor(private activatedRoute: ActivatedRoute){} ngOnInit(): void { - //TODO consider using Angular's ActivatedRoute here instead - const params = new URLSearchParams(window.location.search); - const names = params.get('names')?.replaceAll(',', '\n'); - if (names) this.playerNamesValue = names; + this.activatedRoute.queryParams.subscribe(params => { + const names = params['names']?.replaceAll(',', '\n'); + if (names) { + this.playerNamesValue = names; + } + }); } onButtonGenerate(textinput: string): void{