angular - ionic /Angular : The pipe 'async' could not be found

标签 angular ionic-framework

当试图访问可观察的 holidayEntries$: Observable<HolidayEntry[]>在 html 中

<ion-list lines="full" *ngFor="let holiday of holidayEntries$ | async">
    <ion-label>
        <h1>{{ holiday.author }}</h1>
    </ion-label>
</ion-list>
我总是收到以下错误:

core.js:6228 ERROR Error: Uncaught (in promise):
Error: The pipe 'async' could not be found!


我读过 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())
  }
}

最佳答案

如果您正在加载的路由上的组件未声明(通过声明:[]),那么您也会收到此类错误。从功能模块中删除功能组件的声明并添加到 app.module.ts (通过声明:[])

关于angular - ionic /Angular : The pipe 'async' could not be found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64423745/

相关文章:

javascript - 使用 AngularJS 在 Controller 中动态创建项目

android - Ionic 应用程序在 Android 模拟器和设备上崩溃

angular - Ionic 3文件夹结构

cordova - ionic 2 : Get size cache directory and clear it

angularjs - 在Ionic中呈现HTML内容

javascript - 使用 formArray 时出现 Mat-AutoComplete 错误

javascript - 将 session 存储值更改为未定义应该会影响 ngIf,而无需单击两次

angular - 如何在 Angular 的提供程序配置期间从 useFactory 函数进行 HTTP 调用?

angular - Angular2 表单中的自定义验证

Angular:如何更好地处理嵌套 API 调用,特别是当后者依赖于前者的结果时