【发布时间】:2021-07-23 05:17:46
【问题描述】:
我有一个 Observable 数组,我想通过一些属性对其进行过滤。但是,过滤不起作用。
我尝试调试代码,但它好像没有进入pipe(map(... 部分。
ngOnInit() {
this.bookService.getBooks().subscribe(res => {
this.store.dispatch(listBooks({ books: res }));
});
this.filterForm = this.formBuilder.group({
name: [""],
author: [""],
release_year: [""]
});
this.filterForm.valueChanges.subscribe(val => {
this.books$.pipe(map(books =>
books.filter(b => {
return b.name.startsWith(val.name) &&
b.author.startsWith(val.author) &&
b.release_year.startsWith(val.release_year)
})
))
})
【问题讨论】:
标签: angular typescript rxjs observable