1
我有兩個文件:x.component和x.service如何獲得商店並指定爲窺探可變
x.service.ts
store$: Store<DogsStore>;
constructor(private store: Store<DogsStore>) {
this.store$ = store;
}
x.component.ts
constructor(private xService: X) {}
ngOnInit() {
this.xService.store$.select('something').subscribe(...)
}
測試x.component
我收到一個錯誤cannot subscribe of undefined
。在x.spec.ts
我使用x.service.spy.ts在那裏我有
store$: Store<DogsStore>;
,你可以看到,因爲我不能使用類似store$: Store<DogsStore> = new Store()
我沒有初始化。我如何獲得商店並將其分配給變量?也許還有其他問題要做?