這裏ItemService
item.service.ts類型 '可觀察<{}>' 是不能分配給輸入「可觀察<Item[]>:Rxjs
export const items = (state: any = [], {type, payload}) => {
switch (type) {
default:
return state;
}
};
export interface Item {
id: number;
name: string;
description: string;
};
export interface AppStore {
items: Item[];
selectedItem: Item;
};
@Injectable()
export class ListService {
items: Observable<Array<Item>>;
private listModel: ItemList = new ItemList();
constructor(private itemListApi: ItemListApi, private store: Store<AppStore>) {
this.items = store.select('items');===>Error
}
}
我收到一條錯誤this.items
。錯誤是「Type」Observable < {}>'不可分配給'Observable'類型。什麼地方出了錯?對此有何幫助?
感謝它的工作原理。 – Khushi