Angular7:模板解析错误:找不到管道“ titlecase” /“ slice”

时间:2018-11-22 12:06:32

标签: javascript angular typescript angular2-template angular7

我正在将我的应用程序从 Angular 6 迁移到 Angular 7

运行ng update并更新我的软件包后,一切顺利,直到我运行:

ng build --configuration=production 

似乎找不到一些有角度的知名管道: titlecase / slice

ERROR in : Template parse errors:
The pipe 'titlecase' could not be found ("span class="nav-item border-left text-truncate px-2 text-left">
    <span class="text-capitalize">{{[ERROR ->]username | titlecase }}</span>
    <span class="text-capitalize">&nbsp;</span>
    <span class="text-"): /media/khalidvm/SecondDisk/SOCLE_RCD/Front/Frontend_v3_crmd/src/app/Features/CRMD/navbar-crmd/navbar-crmd-components/navbar-crmd/navbar-crmd.component.html@14:36
The pipe 'slice' could not be found ("ecase }}</span>
    <span class="text-capitalize">&nbsp;</span>
    <span class="text-capitalize">{{[ERROR ->]userlastname | slice:0:1}} </span>
    <span class="text-capitalize">&nbsp;</span>
    <span>-</span>"): /media/khalidvm/SecondDisk/SOCLE_RCD/Front/Frontend_v3_crmd/src/app/Features/CRMD/navbar-crmd/navbar-crmd-components/navbar-crmd/navbar-crmd.component.html@16:36

我的组件看起来像这样:

<div id="HeaderNav" class="nav bg-white mx-auto py-1 d-flex  flex-nowrap">
  <span class="nav-item dropdown mx-1">
    <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
      <span class="icon svg-avatar"></span>
    </a>
    <ul class="dropdown-menu">
      <a class="dropdown-item disabled">Profil Conseiller</a>
      <a class="dropdown-item" *ngIf="srcdPiloteViewAccess" (click)="goSrcdView()">Devenir Pilote</a>
      <a class="dropdown-item" *ngIf="administrationViewAccess" (click)="goAdministrationView()">Devenir Administrateur</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" (click)="logout()">Se déconnecter</a>
    </ul>
  </span>
  <span class="nav-item border-left text-truncate px-2 text-left">
    <span class="text-capitalize">{{username | titlecase }}</span>
    <span class="text-capitalize">&nbsp;</span>
    <span class="text-capitalize">{{userlastname | slice:0:1}} </span>
    <span class="text-capitalize">&nbsp;</span>
    <span>-</span>
    <span class="text-capitalize">&nbsp;</span>
    <span class="text-capitalize">boutique orange {{shopName}}</span>
  </span>
  <span class="nav-item text-truncate text-center en-attente">
    <!--<span class="nav-item">4 personnes en attente</span>-->
  </span>
  <span class="espace-vide"></span>
</div>

因此,我已经验证了模块 NgModule ,并且很好地导入了 CommonModule

但是在构建应用程序时,它们会丢失

建议?

1 个答案:

答案 0 :(得分:1)

我有这个完全相同的问题。稍加挖掘,我发现它与您的TS配置中的having Ivy enabled有关。

我要解决的是从tsconfig.json中删除以下配置:

"angularCompilerOptions": {
    "enableIvy": true
}