Closed gnu4cn closed 3 years ago
Can you explain... looks like a required parameter of RouterService#activateRoute
Can you explain... looks like a required parameter of
RouterService#activateRoute
Exactly it's not need to pass a snapshot to the activateRoute method. I've test it. We can get all the information from the route url.
That would require rewriting the activateRoute
method:
activateRoute(snapshot: ActivatedRouteSnapshot) {
const url = snapshot.url.map(s => s.path).join('/');
let root = this.router.url;
if (snapshot.fragment) {
root = root.replace(new RegExp('#' + snapshot.fragment + '$'), '');
}
root = root.replace(new RegExp(url + '$'), '');
if (!root.endsWith('/')) {
root += '/';
}
const path = url + (snapshot.fragment ? `#${snapshot.fragment}` : '');
this.go(path, root);
}
In another request, I rewrote the method.
I should make pull requests together.
Pass a snapshot is not need.