【发布时间】:2021-02-02 00:25:07
【问题描述】:
当尝试访问 html 中的 observable holidayEntries$: Observable<HolidayEntry[]> 时
<ion-list lines="full" *ngFor="let holiday of holidayEntries$ | async">
<ion-label>
<h1>{{ holiday.author }}</h1>
</ion-label>
</ion-list>
我总是收到以下错误:
core.js:6228 ERROR 错误:未捕获(承诺中):
错误:找不到管道“异步”!
我读到CommonModule 可能会丢失,就像here 中提到的那样,但我将它导入到相应的.module.ts 文件中。
知道我做错了什么吗?
编辑: 我的模块
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HolidaysPageRoutingModule
],
declarations: [HolidaysPage]
})
export class HolidaysPageModule {}
我的组件
@Component({
selector: 'app-tab2',
templateUrl: './holidays.page.html',
styleUrls: ['./holidays.page.scss'],
})
export class HolidaysPage implements OnInit {
currentUser$: Observable<UserVM>;
holidayEntries$: Observable<HolidayEntry[]>;
constructor(
private readonly appStore: Store<fromApp.State>,
private readonly holidayStore: Store<fromHoliday.State>) {
this.currentUser$ = appStore.select(fromAuth.selectAuthUser).pipe(
map(user => new UserVM(user))
);
this.holidayEntries$ = holidayStore.select(fromHoliday.selectHolidayEntries)
}
loadHolidays() {
console.log("loading holidays")
this.holidayStore.dispatch(HolidayActions.loadHolidayRequests())
}
}
【问题讨论】:
-
你使用的是什么版本的 Angular
-
你能展示你的组件的(基本)代码吗?不需要所有方法,只需要类声明和构造函数。还有声明组件的 NgModule。
-
@DTul 版本 9.1.6
-
@MarcSances 更新了我的问题。我还使用 NgRx Effect 来加载数据。但这是否会以任何方式影响管道错误?
-
根据我的经验,当其他部分出现问题时也会出现错误。看起来 Angular Ivy 默默地传递了错误。所以尝试检查其他相关模块的导入和依赖项