Han Che
Han Che

Reputation: 8519

angular ActivatedRoute.queryParams doesn't allow rxjs operators?

Hi I have a subscription on the queryParams like

this.route.queryParams
    .skip(1)
    .subscribe((res: DataParameter) => {})

It gives me the type error

this.route.queryParams.skip is not a function

same goes for the distincUntilChanged operator. Is there something I'm missing, in the docs it says it returns an Observable.

Thanks!

Upvotes: 1

Views: 641

Answers (1)

Kim Kern
Kim Kern

Reputation: 60377

Did you import the operator?

import 'rxjs/add/operator/distinctUntilChanged';

Because the rxjs package is very large, only a small subset of operators is imported by default.

=== Update Dec 2017 ===

As of today, pipeable operators are the new and preferred way of importing and using rxjs operators. For further information, have a look at the rxjs docs.

import { map, filter, scan } from 'rxjs/operators';
source$.pipe(
  filter(x => x % 2 === 0),
  map(x => x + x),
  scan((acc, x) => acc + x, 0)
)

Upvotes: 3

Related Questions