【问题标题】:Angular2 module component giving me error pipe can not be found找不到给我错误管道的Angular2模块组件
【发布时间】:2018-01-14 01:28:56
【问题描述】:

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

{{obj|json}}

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

【问题讨论】:

标签: javascript angular2-routing


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    下面是测试代码,它很简单:

    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'];
    
    } 
    

    app.component.html

    {{ obj |  json }}
    

    浏览器输出

    [“test1”,“test2”,“test3”]

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

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

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

    【讨论】:

    • 我的项目中有两个模块,它在一个模块的组件中运行良好,但在其他模块的组件中不工作。
    • 你能把你的代码粘贴在这里或plunker上,以便检查可能的错误吗?
    • 我发现我在第三个模块中使用了组件,并且该模块中没有 CommonModule 并且它正在产生问题。谢谢它现在正在工作,
    猜你喜欢
    • 2016-02-16
    • 2017-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-28
    • 2017-02-17
    • 2016-12-26
    • 1970-01-01
    相关资源
    最近更新 更多