【问题标题】:How to pass props to child selector in selector ngrx anguar 7如何在选择器ngrx angular 7中将道具传递给子选择器
【发布时间】:2019-07-12 09:49:49
【问题描述】:

我可以像这样将道具传递给 store/index.ts ngrx 7 angular 7 中的所有子选择器吗:

我将调用组件: 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;
    }
  }
);

【问题讨论】:

  • 如果我们信任文档,您应该能够做到这一点,您遇到任何问题吗?
  • 我不能。 selectUserById 返回未定义

标签: angular parameters selector ngrx


【解决方案1】:

{id: this.id} 会通过您所有的子选择器。

【讨论】:

  • 我不能。 selectUserById 返回未定义
猜你喜欢
  • 2020-02-15
  • 2019-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-13
  • 1970-01-01
  • 2018-09-22
  • 2012-04-24
相关资源
最近更新 更多