my frontend is in http://host:4200 and when the other frontend wants to open it for example with window.open(http://host:4200?username=a&department=b) so this http://host:4200?username=a&department=b will be in the address bar, How can I remove query parameters from this url?
if i use this two lines of code to hie the query params it works but with delay, because i remove after reading url so for a second query params are visible:
const url1 = window.location.toString();
const sanitizedUrl = url1.substring(0, url1.indexOf('?'));
window.history.replaceState({}, document.title, sanitizedUrl);
This is my cpp.component.ts code which i need to read query params in it, it s with angular 5,
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
username = '';
department = '';
constructor(
private feedbackService: ApiService,
private titleService: Title,
private route: ActivatedRoute) {
}
ngOnInit() {
this.route.queryParams.subscribe(params => {
if (params.hasOwnProperty('username')) {
this.username = params['username'];
}
if (params.hasOwnProperty('department')) {
this.department = params['department'];
}
});
}