-
Notifications
You must be signed in to change notification settings - Fork 120
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
Angular Universal with highcharts-angular Getting Console Error when i run the project using dev:ssr and build:ssr ERROR TypeError: this.Highcharts[(this.constructorType || "chart")] is not a function #216
Comments
You can find a detailed explanation below:
Since its a common question if think that we should mention about it in the |
@mateuszkornecki I try with the approach mentioned in your comment. But still I am getting error in node console. I tried all the solution mentioned in "highcharts-react" its now working for "highcharts-angular". Is there any other solution available for Angular Universal approach please help me on this. |
I cloned your repository. It seems that the fix that I suggested previously won't be that straightforward that I thought. I will try to fix that from the wrapper level in the upcoming release. But till then to fix the problem you need to add a simple condition that will check if the code is running on the browser or not (or simply check if the export class AppComponent implements OnInit {
isHighcharts = typeof Highcharts === 'object';
title = 'UnivHighCharts';
Highcharts: typeof Highcharts = Highcharts;
chartConstructor: string = 'chart';
chartOptions: Highcharts.Options = {};
ngOnInit() {
this.chartOptions = {
series: [{
data: [1, 2, 3],
type: 'line'
}]
};
}
} <highcharts-chart
*ngIf="isHighcharts"
[Highcharts]="Highcharts"
[constructorType]="chartConstructor"
[options]="chartOptions"
style="width: 100%; height: 400px; display: block;"
></highcharts-chart> |
@mateuszkornecki thanks for your update. Above solution works for in Angular Universal application. |
I have created simple angular universal (
@nguniversal/express-engine
) application and simple 'highcharts-angular
' in app.component.While running this project using 'ng serve' I am not getting any error in browser and node console.
When I run the project using "dev:ssr" or "build:ssr && serve:ssr" getting below error.
I didn't find any jsfiddle to demo the code. Below github repo my code is available.
https://github.com/karthikeyansgit/UnivHighCharts
Anyone please suggest me how to fix this issue.
The text was updated successfully, but these errors were encountered: