Search code examples
angularangular7angular7-router

Angular 7: flatMap is not a function


I am migrating from angular 5 to angular 7, its when I am getting this error when I do npm start.

const config = this.router.events.pipe(
skipWhile(() => !this.router.navigate),
take(1),
flatMap(() => this.route.queryParams.pipe(take(1)).flatMap(params => {

Other details as below:

private route: ActivatedRouter
private router: Router
rxjs version is ^6.3.3

Replacing flatMap with MergeMap is a good option? If so, do I need to change the code as well? What should I do?

enter image description here


Solution

  • You need to add flatMap inside pipe operator like you did with take(1)

    try this:

    this.route.queryParams.pipe(take(1), flatMap(params => {
    })