繁体   English   中英

找不到给我错误管道的 Angular2 模块组件

[英]Angular2 module component giving me error pipe can not be found

找不到给我错误管道的 Angular2 模块组件

{{obj|json}}

找不到管道 json。 错误的可能原因是什么?

以下是测试代码,它可以正常工作:

app.component.ts

import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

  obj : any = ['test1', 'test2', 'test3'];

} 

应用程序组件.html

{{ obj |  json }}

浏览器输出

[“测试1”,“测试2”,“测试3”]

您可以在此处粘贴代码,以便我们可以检查您在管道上遗漏的确切位置。

您可以在此处查看有关 Jsonpipe 的更多信息

https://angular.io/api/common/JsonPipe

在我的情况下,它只是重新启动应用程序并且它起作用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM