Reputation: 106
As above, when I try to use async keyword I am getting in the browser error. I am importing CommonModule in my custom module. Can't find the reason why it's not working.
Error:
ERROR Error: The pipe 'async' could not be found!
Angular 2
getPipeDef$1
pipe
Node: 12.19.0
OS: linux x64
Angular: 10.2.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1002.3
@angular-devkit/build-angular 0.1002.3
@angular-devkit/core 10.2.3
@angular-devkit/schematics 10.2.3
@angular/cli 10.2.3
@schematics/angular 10.2.3
@schematics/update 0.1002.3
rxjs 6.6.7
typescript 4.0.7
Module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
]
})
export class IngenicoPaymentMethodModule { }
My component
import { Component, OnInit } from '@angular/core';
import { ActiveCartService, UserIdService } from '@spartacus/core';
import { Observable } from 'rxjs';
import { PaymentMethodService, PaymentProduct } from './facade/payment-method.service';
@Component({
selector: 'app-ingenico-payment-method',
templateUrl: './ingenico-payment-method.component.html',
styleUrls: ['./ingenico-payment-method.component.scss']
})
export class IngenicoPaymentMethodComponent implements OnInit {
paymentMethods$: Observable<PaymentProduct[]>;
constructor(
protected paymentMethodService: PaymentMethodService,
protected activeCartService: ActiveCartService,
protected userIdService: UserIdService) { }
ngOnInit(): void {
let userId, cartId;
this.userIdService.getUserId()
.subscribe(occId => userId = occId)
.unsubscribe();
this.activeCartService.getActiveCartId().subscribe(occId => cartId = occId).unsubscribe();
if (userId && cartId) {
this.paymentMethods$ = this.paymentMethodService.getPaymentMethods(userId, cartId);
}
}
}
Template
<ng-container *ngIf="paymentMethods$ | async as paymentMethods"></ng-container>
As you can see above I am importing CommonModule, yet it's not visible by the browser.
Upvotes: 0
Views: 596
Reputation: 1221
Please declare your component in the same module where you import the CommonModule
. Only then the async
pipe will be accessible in the component's template:
@NgModule({
imports: [
CommonModule
],
declarations: [IngenicoPaymentMethodComponent] // <----------------
})
export class IngenicoPaymentMethodModule { }
Upvotes: 3
Reputation: 742
You can opt out of Ivy usage by setting:
"angularCompilerOptions": {
"enableIvy": false
}
in your tsconfig.app.json
and this should fix your issue.
Upvotes: -1