Angular 7 找不到管道

编程入门 行业动态 更新时间:2024-10-27 08:25:17
本文介绍了Angular 7 找不到管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试构建我的 Angular 7 项目,但每次我收到错误提示

I'm trying to build my Angular 7 project but every time I get an error saying

模板解析错误:找不到管道货币".

Template parse errors: The pipe 'currency' could not be found.

但是当我尝试运行 ng serve 它确实按预期工作

But when I try to run the ng serve it does works as expected

我尝试使用 --prod 标志构建它,但它不起作用.如果我删除生产标志,它会正确构建.

I've tried to build it with the --prod flag, and it doesn't work. If I remove the production flag, it builds correctly.

推荐答案

为了使用管道,您首先需要在模块声明中添加管道:

In order to use pipes, you first need add pipe to your module declarations:

import {CurrencyPipeComponent}  from './currencypipeponent';

@NgModule({
  imports:      ...,
  declarations: [
                 ...,
                 CurrencyPipeComponent],
})
export class YourModuleWhichYourComponentIsRegistered { } 

这篇关于Angular 7 找不到管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 16:01:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1027071.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   管道   Angular

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!