You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入DecimalPipe后仍出现NullInjectorError: No provider for DecimalProvider错误求助

Angular DecimalPipe 注入错误排查

我遇到了如下错误:

NullInjectorError: R3InjectorError(StudentModule)[DecimalProvider -> DecimalProvider -> DecimalProvider -> DecimalProvider]:

错误截图:
DecimalPipe注入错误截图

我已在模块中导入DecimalPipe,但错误依旧。尝试过执行npm cache clean --force清理缓存,重新加载项目,再运行npm install和npm start,问题仍未解决。

以下是StudentModule的代码:

import { DatePipe, DecimalPipe } from '@angular/common';

@NgModule({
  imports: [
    // 其他导入模块
    CommonModule,
  ],
  providers: [DecimalPipe],
  exports: []
})
export class StudentModule { }

为何在模块中导入DecimalPipe后仍出现该错误?


内容的提问来源于stack exchange,提问作者Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 03:55:27