Angular 7 doesn't find pipes

 ̄綄美尐妖づ 提交于 2019-12-08 04:55:18

问题


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

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

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

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


回答1:


Try this: in tsconfig.json change

"angularCompilerOptions": {
    "enableIvy": true
}

for

"angularCompilerOptions": {
    "enableIvy": false
}



回答2:


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

import {CurrencyPipeComponent}  from './currencypipe.component';

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


来源:https://stackoverflow.com/questions/53503724/angular-7-doesnt-find-pipes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!