如何将道具传递给选择器ngrx anguar 7中的子选择器

时间:2019-07-12 09:49:49

标签: angular parameters selector ngrx

我可以将道具传递给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;
    }
  }
);

1 个答案:

答案 0 :(得分:0)

{id: this.id}通过所有子选择器传递。