【问题标题】:Angular7: Template parse errors: The pipe 'titlecase' / 'slice' could not be foundAngular7:模板解析错误:找不到管道'titlecase'/'slice'
【发布时间】:2019-04-25 02:52:49
【问题描述】:

我正在将我的应用从 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

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

建议?

【问题讨论】:

标签: javascript angular typescript angular2-template angular7


【解决方案1】:

我遇到了同样的问题。经过一番挖掘,我发现它与您的 TS 配置中的 having Ivy enabled 有关。

我解决这个问题的方法是从tsconfig.json删除以下配置:

"angularCompilerOptions": {
    "enableIvy": true
}

【讨论】:

  • 我已经导入了这个选项,但仍然有同样的问题
  • 删除它会导致另一个错误错误:没有可用于依赖类型的模块工厂:ContextElementDependency
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-03
  • 2017-05-27
  • 2019-10-09
  • 2018-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多