为什么这不起作用?
import { forkJoin } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
constructor(
private route: ActivatedRoute
) {}
ngOnInit(): void {
let parent = this.route.parent.params;
let child = this.route.params;
forkJoin(
parent,
child,
(p, c) => {
console.log(p);
console.log(c);
}
)
}
FYI(rxjs6)
答案 0 :(得分:3)
import { combineLatest } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
constructor(
private route: ActivatedRoute
) {}
ngOnInit(): void {
combineLatest(
this.route.parent.params,
this.route.params
).subscribe(
([p, c]) => {
console.log(p);
console.log(c);
}
);
}