eChart异常(NgxEchartsDirective-> InjectionToken NGX_ECHARTS_CONFIG) [英] eChart exception (NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG)
问题描述
我在angular 7应用程序中使用ngx-echart.我正在跟踪链接中的示例: https://www.freakyjolly.com/使用ngx-echarts-tutorial/#.XwSANigzaUk的angular-e-charts
I am using ngx-echart in angular 7 application. I am following the example in the link: https://www.freakyjolly.com/angular-e-charts-using-ngx-echarts-tutorial/#.XwSANigzaUk
但是当执行(执行服务)应用程序并显示组件时,出现以下错误:
But when executing (ng serve) the application, and display the component, I am getting the below error:
错误错误:StaticInjectorError(AppModule)[NgxEchartsDirective->InjectionToken NGX_ECHARTS_CONFIG]:StaticInjectorError(Platform:核心)[NgxEchartsDirective->InjectionToken NGX_ECHARTS_CONFIG]:NullInjectorError:没有InjectionToken NGX_ECHARTS_CONFIG的提供程序!在NullInjector.push ../node_modules/@angular/core/fesm5/core.js.NullInjector.get(core.js:8896)在resolveToken(core.js:9141)在tryResolveToken(core.js:9085)在StaticInjector.push ../node_modules/@angular/core/fesm5/core.js.StaticInjector.get(core.js:8982)在resolveToken(core.js:9141)在tryResolveToken(core.js:9085)在StaticInjector.push ../node_modules/@angular/core/fesm5/core.js.StaticInjector.get(core.js:8982)在resolveNgModuleDep(core.js:21218)在NgModuleRef_.push ../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get(core.js:21907)在resolveNgModuleDep(core.js:21218)
ERROR Error: StaticInjectorError(AppModule)[NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG]: StaticInjectorError(Platform: core)[NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG]: NullInjectorError: No provider for InjectionToken NGX_ECHARTS_CONFIG! at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8896) at resolveToken (core.js:9141) at tryResolveToken (core.js:9085) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8982) at resolveToken (core.js:9141) at tryResolveToken (core.js:9085) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8982) at resolveNgModuleDep (core.js:21218) at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:21907) at resolveNgModuleDep (core.js:21218)
有什么主意吗?
谢谢
推荐答案
您需要在模块中添加 NgxEchartsModule.forRoot({echarts})
import { NgxEchartsModule } from 'ngx-echarts';
import * as echarts from 'echarts';
这篇关于eChart异常(NgxEchartsDirective-> InjectionToken NGX_ECHARTS_CONFIG)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!