Angular 2中的JSON管道无法正常工作 [英] JSON pipe in Angular 2 is not working

查看:301
本文介绍了Angular 2中的JSON管道无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过JSON管道传输数据时,在控制台中出现以下错误:

When I try to pipe my data by JSON pipe I get the following error in the console:

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

我在做什么错了?

推荐答案

您很可能忘记了导入CommonModule:

import { CommonModule } from '@angular/common';


@NgModule({
    ...
    imports: [ CommonModule ]
    ...
})

如注释中所述,请在使用json管道的模块中执行此操作.

As noted in the comments, do this in the module where you're using the json pipe.

这篇关于Angular 2中的JSON管道无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆