The Angular Material Documentation application fetches route parameters from lazy loaded route modules in the following way:
// Merge parameters from all paths into a single object.
this.params = combineLatest(
this._route.pathFromRoot.map(route => route.params), Object.assign);
Do we actually need to use combineLatest
for this?
The _route
is injected in the constructor, and as I understand it, once the component has a reference to it, the pathFromRoot
array of the ActivateRoute
instance cannot change.
If that's the case, then do we really require combineLatest
?
It seems like we could potentially simplify it like this instead:
const paramArr = this._route.pathFromRoot.map(route => route.params)
this.params = of(Object.assign(paramArr))
Does this approach sound logical?