找不到管道''-Angular升级后出错

Pio*_*app 4 typescript 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
Run Code Online (Sandbox Code Playgroud)

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

结果如下:

  • ng build --prod app 产生以上错误
  • ng build app 可以100%罚款

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

Nil*_*dri 5

从您的tsconfig.json中看来,您正在Angular 7项目中使用Ivy渲染器

如下 -

"angularCompilerOptions": {
    "enableIvy": true
  }
Run Code Online (Sandbox Code Playgroud)

您可以做到,"enableIvy": false然后再次尝试生产。

在生产构建(ng build --prod)期间,由于树木摇晃,它会移除管道。Ivy尚不完全兼容,只能用于测试目的。在使用Ivy之前,您需要运行ngcc转换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

  • @PiotrStapp 不客气:) .. 我希望这也能帮助其他人 (2认同)