无法找到管道’ – Angular升级后出错

前端之家收集整理的这篇文章主要介绍了无法找到管道’ – Angular升级后出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将Angular 4升级到最新版本(7.0.3),一切顺利,直到生产编译.我收到了:

ERROR in : Template parse errors:
The pipe 'filter' could not be found ("v class="form-group">
    <ul class="ui-select-list">
      <li [attr.name]="item.id" *ngFor="let [ERROR ->]item of data | filter : qModel" innerHtml="{{ 'AAA' | translate }}"></li>
    </ul>
</div>
"): C:/x/src/app/components/ui/fields/combo/ui.combo.html@2:44
The pipe 'translate' could not be found ("s="ui-select-list">
      <li [attr.name]="item.id" *ngFor="let item of data | filter : qModel" inn[ERROR ->]erHtml="{{ 'AAA' | translate }}"></li>
    </ul>
</div>
"): C:/x/src/app/components/ui/fields/combo/ui.combo.html@2:79

为了重现错误,我从我的代码创建了一个最小的存储库:https://github.com/ptrstpp950/myBugInAngular

结果如下:

> ng build –prod app产生以上错误
> ng build app工作100%罚款

我尝试阅读共享模块中的管道,我试图根据指南进行更改,但仍然没有成功.

解决方法

从您的tsconfig.json中,您似乎在Angular 7项目中使用Ivy渲染器

如下 –

"angularCompilerOptions": {
    "enableIvy": true
  }

你可以使它成为“enableIvy”:false并再次尝试生产构建.

在生产构建期间(ng build –prod),它会因树木抖动而移除管道. Ivy尚未完全兼容,它只能用于测试目的.在使用Ivy之前,你需要运行ngcc来转换pre-Ivy包以包含Ivy定义,ngcc是来自@ angular / compiler-cli的命令行工具.

有关常春藤渲染器的信息,请参阅以下链接

https://github.com/angular/angular/blob/master/packages/core/src/render3/STATUS.md#implementation-status

https://github.com/angular/angular/issues/26436

猜你在找的Angularjs相关文章