[英]read.ts(6133) Module '“../../../node_modules/rxjs/observable/combineLatest”' has no exported member 'combineLatest'.ts(2305)
How to combine Observables by combineLatest. 如何通过CombineLatest合并Observable。 combineLatest is not defined 未定义CombineLatest
I am using angular js 7.I want to marge tow query string parameter but when I write the obserable.combinelaste([]) then it will give en error. 我正在使用angular js7。我想添加两个查询字符串参数,但是当我编写obserable.combinelaste([])时,它将给出en错误。
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, of, observable } from 'rxjs'
import { combineLatest } from 'rxjs/observable/combineLatest';
@Component({
selector: 'app-githubfollowers',
templateUrl: './githubfollowers.component.html',
styleUrls: ['./githubfollowers.component.css']
})
export class GithubfollowersComponent implements OnInit {
constructor(private rout:ActivatedRoute ) { }
ngOnInit() {
Observable.combineLatest([ this.rout.paramMap,
this.rout.queryParamMap
]);
this.rout.paramMap.subscribe(prams=>{
});
this.rout.queryParamMap.subscribe(prams=>{
});
}
}
You import is wrong. 您输入错误。 You used the import for RXJS v5. 您将导入用于RXJS v5。
For RxJS v6+, you should use this import : 对于RxJS v6 +,您应该使用以下导入:
import { combineLatest } from 'rxjs';
To solve the following error message : 解决以下错误信息:
ngOnInit() { Observable.combineLatest([ this.rout.paramMap, this.rout.queryParamMap ]); ngOnInit(){Observable.combineLatest([this.rout.paramMap,this.rout.queryParamMap]); Property 'combineLatest' does not exist on type 'typeof Observable 类型“ typeof Observable”上不存在属性“ combineLatest”
You can use combineLatest
like this : 您可以像这样使用combineLatest
:
combineLatest(this.rout.paramMap, this.rout.queryParamMap)
And you probably have to spend some time to read how to use it: https://www.learnrxjs.io/operators/combination/combinelatest.html 您可能需要花一些时间来阅读如何使用它: https : //www.learnrxjs.io/operators/combination/combinelatest.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.