Use DOCUMENT and Router to make the URL String with Params.
import DOCUMENT into a component from platform-browser and Router form @angular/router
import { DOCUMENT } from '@angular/platform-browser';
import { Router } from '@angular/router';
Initialize constructor
constructor(
private router: Router,
@Inject(DOCUMENT) private document: any
) {}
make URL using
ngOnInit() {
let domain = this.document.location.hostname;
this.href = this.router.url;
console.log(domain+this.href)
}
Working Sample - Stackblitz code is in the child-one component
------------ EDITED AFTER COMMENTS -------------
use DOCUMENT to get domain/hostname and concat parameters to that domain.
import { DOCUMENT } from '@angular/platform-browser';
import {ActivatedRoute} from '@angular/router';
constructor(
@Inject(DOCUMENT) private document: any,
private route:ActivatedRoute
) {}
ngOnInit() {
let domain = this.document.location.hostname;
let userId = this.route.snapshot.params['userId'];
console.log(domain+'?user='+userId)
}