Код: Выделить всё
X [ERROR] NG8004: No pipe found with name 'async'.
To fix this, import the "AsyncPipe" class from "@angular/common" and add it to the "imports" array of the module declaring the component. [plugin angular-compiler]
src/app/async-test/async-test.html:1:9:
1 │ {{v | async }}
╵ ~~~~~
Error occurs in the template of component AsyncTestComponent.
src/app/async-test/async-test.ts:6:15:
6 │ templateUrl: './async-test.html',
╵ ~~~~~~~~~~~~~~~~~~~
Тест:
Код: Выделить всё
describe('AsyncTestComponent', () => {
let component: AsyncTestComponent;
let fixture: ComponentFixture;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CommonModule, AsyncPipe ],
declarations: [AsyncTestComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AsyncTestComponent);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Код: Выделить всё
@Component({
selector: 'app-async-test',
templateUrl: './async-test.html',
styleUrl: './async-test.css',
standalone: false
})
export class AsyncTestComponent {
protected readonly v = of(1);
}
Код: Выделить всё
{{v | async }}
Код: Выделить всё
ng newСталкивался ли кто-нибудь еще с такой же проблемой?
Подробнее здесь: https://stackoverflow.com/questions/798 ... async-pipe
Мобильная версия