Answer the question
In order to leave comments, you need to log in
How to get a request from the address bar and process it?
Good afternoon!
There is a task (in Angular) that seems not difficult, but I don’t understand how to approach it!
The user enters such parameters in the address bar and it should be automatically redirected to the address
Created Routing and 2 components Main and Second. Further I will not understand where to dig! http://localhost:4200/?page=main&id=3
http://localhost:4200/main/3
Answer the question
In order to leave comments, you need to log in
I would do something like this
ngOnInit() {
this.activatedRoute.queryParams.subscribe(params => {
if(Object.keys(params).length){
window.location.href = window.location.origin + '/' + (Object.values(params)).join('/')
}
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question