Observable.combineLatest不是函数

Ban*_*dem 2 routerlink angular

我有一个主页,用户在其中单击“ 联系我”以将其重定向到“ 联系”页面:

home.component.html

<div>
  <a routerLink="/contact" [queryParams]="sendOBj">Contact me</a>
</div>
Run Code Online (Sandbox Code Playgroud)

home.component.ts:

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '../../../node_modules/@angular/router';
import { FollowersService } from '../followers.service';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

  myfollowers: any[]; 
  sendOBj: {id: any, name: any};

  constructor(private followers: FollowersService, private route: ActivatedRoute) { }

  ngOnInit() {
    this.myfollowers = this.followers.getFollowers();   
    this.sendOBj = {id: this.myfollowers[0].id, name: this.myfollowers[0].name };
  }

}
Run Code Online (Sandbox Code Playgroud)

contact.component.ts:

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '../../../node_modules/@angular/router';
import { Observable } from '../../../node_modules/rxjs/Observable';
import 'rxjs/observable/combineLatest';


@Component({
  selector: 'app-contact',
  templateUrl: './contact.component.html',
  styleUrls: ['./contact.component.css']
})
export class ContactComponent implements OnInit {

  constructor( private route: ActivatedRoute) { }

  ngOnInit() {

    Observable.combineLatest([
      this.route.queryParamMap
    ])
      .subscribe(
        combined=>{
          let id = combined[1].get('id');
          console.log('id', id);
        }
      );

    this.route.queryParamMap.subscribe();    
  }
}
Run Code Online (Sandbox Code Playgroud)

通过点击联系我家庭,我得到这个错误:

ContactComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Observable_1.Observable.combineLatest is not a function
Run Code Online (Sandbox Code Playgroud)

请帮助我找出问题所在。

Wan*_*lle 7

在角度6中

您只需:

import {combineLatest} from "rxjs/index";
Run Code Online (Sandbox Code Playgroud)

并更换

Observable.combineLatest(...)
Run Code Online (Sandbox Code Playgroud)

通过

combineLastest(...)
Run Code Online (Sandbox Code Playgroud)