我可以将道具传递给store / index.ts ngrx 7 angular 7中的所有子选择器吗?
我将调用component: this.filteredUser = this.store.pipe(select(selectVisibleBooks,{id:this.id}));
export const selectUserById = createSelector(
selectUserEntities,
(entities, props) => props.id && entities[props.id]
);
export const selectVisibleBooks = createSelector(
selectUserById(props), // I want use prop id here
selectAllBooks,
(selectedUser: User, allBooks: Book[]) => {
if (selectedUser && allBooks) {
return allBooks.filter((book: Book) => book.userId === selectedUser.id);
} else {
return allBooks;
}
}
);
答案 0 :(得分:0)
{id: this.id}
通过所有子选择器传递。