本文介绍了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:关键词]
发布评论