我正试图在我的Angular 5项目中的ngrx效果中访问我的商店的一部分。根据StackOverflow上的几个主题,以及一些博客文章,我使用了withLatestFrom和我的注入商店。我目前正在使用Angular 5,ngrx 4.1.1和rxjs 5.5.2
我的问题是,我一直收到类型错误:
error TS2339: Property 'withLatestFrom' does not exist on type 'Actions<Action>'.
这是我正在使用的代码。关于可能导致这种情况的任何想法?
import {Injectable} from '@angular/core';
import {Store} from '@ngrx/store';
import {Effect, Actions} from '@ngrx/effects';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/withLastestFrom';
import * as EndpointActions from './endpoint.actions';
import {AppState} from '../../store/app.reducers';
@Injectable()
export class EndpointEffects {
@Effect()
setEndpointData = this.actions$
.ofType(EndpointActions.SET_ENDPOINT_DATA)
.withLatestFrom(this.store$.select(state => state.endpoint.endpointAddress))
.map(([action, endpointAddress]) => {
return {
type: EndpointActions.TRY_ENDPOINT_ADDRESS,
payload: {endpointAddress: endpointAddress}
};
});
constructor(private actions$: Actions, private store$: Store<AppState>) {}
}
答案 0 :(得分:2)
看起来像一个错字。我相信:
import 'rxjs/add/operator/withLastestFrom';
应该是:
import 'rxjs/add/operator/withLatestFrom';