Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NgxEchartsModule.forChild() not working after upgrading to ngx-echarts 8.0.0 and Angular 13 #334

Closed
jkasperbl opened this issue Dec 6, 2021 · 3 comments · Fixed by #335

Comments

@jkasperbl
Copy link

I am creating an Angular component library to use on a variety of related projects and chose Echarts for our charting solution. I have a global app module which imports NgxEchartsModule.forRoot():

import { NgModule } from "@angular/core";
import { NgxEchartsModule } from "ngx-echarts";

@NgModule({
    imports: [
        NgxEchartsModule.forRoot({
            echarts: () => import('echarts' as 'echarts')
        })
    ]
})
export class GlobalModule { }

I also have a chart component which acts as a simple wrapper. This component is in its own module which imports NgxEchartsModule.forChild():

@NgModule({
    imports: [
        CommonModule,
        NgxEchartsModule.forChild()
    ],
    declarations: [ChartComponent],
    exports: [ChartComponent]
})
export class ChartComponentModule { }

This was working fine with Angular 12 and ngx-echarts 7.0.1, but after upgrading I can no longer build as I get the following error, referring to the NgxEchartsModule.forChild() line:

Value at position 1 in the NgModule.imports of ChartComponentModule is not a reference
Value could not be determined statically.

Unable to evaluate this expression statically.
A value for 'forChild' cannot be determined statically, as it is an external declaration.

Am I doing something wrong or is there a bug here that needs to be fixed? Any prompt assistance would be greatly appreciated.

@jkasperbl
Copy link
Author

FYI I was able to work around this by making the following change to ComponentChartModule:

@NgModule({
    imports: [
        CommonModule,
        {
            ngModule: NgxEchartsModule
        }
    ],
    declarations: [ChartComponent],
    exports: [ChartComponent]
})
export class ChartComponentModule { }

I found that solution by reading the source code for forChild here. That's easy enough, but it would still be better to find a way to make this method work.

@xieziyu
Copy link
Owner

xieziyu commented Dec 7, 2021

Thanks for reporting this issue, please try to upgrade v8.0.1

@jkasperbl
Copy link
Author

@xieziyu That did the trick. Thanks for the quick solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants