JSON pipe in Angular 2 not working

When I try to connect my data via the JSON channel, I get the following error in the console:

Unhandled Promise rejection: Template parse errors: The pipe 'json' could not be found (... 

What am I doing wrong?

+10
source share
2 answers

Most likely, you forgot about importing CommonModule :

 import { CommonModule } from '@angular/common'; @NgModule({ ... imports: [ CommonModule ] ... }) 

As noted in the comments, do this in the module where you use the json feed.

+26
source

Your parent component module should be like this.

 import {NgModule} from '@angular/core'; import {AuditTrailFilterComponent} from './components/audit-trail-filter/audit-trail-filter.component'; import {CommonModule} from '@angular/common'; <-- This is important !!!! @NgModule({ imports: [ CommonModule, <-- This is important !!!! ], declarations: [AuditTrailFilterComponent], exports: [ AuditTrailFilterComponent ] }) export class AuditTrailModule { } 
+4
source

Source: https://habr.com/ru/post/1259181/


All Articles