score:7
mentioning the github issue here. the following solution worked for me.
import { browsermodule } from '@angular/platform-browser';
import { ngmodule } from '@angular/core';
import { appcomponent } from './app.component';
// angular highcharts imports
import {highchartsstatic} from 'angular2-highcharts/dist/highchartsservice';
import { chartmodule } from 'angular2-highcharts';
// factory function
export function highchartsfactory() {
var hc = require('highcharts');
return hc;
}
@ngmodule({
declarations: [
appcomponent
],
imports: [
browsermodule,
chartmodule // import module here
],
providers: [ // provide service here
{
provide: highchartsstatic,
usefactory: highchartsfactory
},
],
bootstrap: [appcomponent]
})
export class appmodule { }
score:0
i've encountered this same issue. try removing the gethighchartsmodule
export from your app.module.ts
and put the exported function in its own file. then import it into app.module.ts
.
i have not figured out why this happens yet.
score:3
i'd like to propose an additional answer if it helps folks get past the error. i had two nearly identical applications on angular 11 sharing the same library module that has a static forroot
method declaration for custom injection configuration.
@ngmodule()
export class themodule {
static forroot(...) {
...
}
}
app a worked as expected, app b threw the error in question.
of course my two apps were different in nature, so this narrows it down to infrastructure
or configuration
differences.
investigation
view the shared module's compiled
code e.g. the-module.module.d.ts
to see if there are differences there:
from the scope of the working application:
// the-module.module.d.ts
import * ...
...
export declare class themodule {
static ɵmod: ɵngcc0.ɵɵngmoduledefwithmeta<themodule, [typeof ɵngcc4.acomponent, ...]
static ɵinj: ɵngcc0.ɵɵinjectordef<themodule>;
}
note the emod
(module) and einj
(injection) definitions.
from the scope of broken app
it is missing these definitions :
// the-module.module.d.ts
export declare class themodule {
}
ok so why is the module empty for the broken app!? it must be something with compilation! looking at the root tsconfig.json
for the broken app:
the following angularcompileroptions
setting was enabled:
// woops, remove this to use the newer compiler for angular versions > 9.0
"angularcompileroptions": {
"enableivy": false
}
this was flack left over from previous days. upon removing this, the error went away, and it enabled the compiler to interact with the shared library module and its types were populated.
when compiling aot take a look at the compiler options documentation: https://angular.io/guide/angular-compiler-options to see the details.
the error message that @angularjs prints, treating it as a decorator
is a "side effect", and unrelated.
score:8
this is a problem with angular in general. angular compiler wants the forroot
code to be completely static.
as an example, in the following code even the assignment of the static variable will cause this error:
static forroot(config: myconfig): modulewithproviders {
myconfigservice.config = config;// this line with cause an error
return {
ngmodule: httptrackerlibmodule,
};
}
if you are not library creator there is nothing much you can do but try library-specific solutions like the one above. but if you are a library creator you can try a static approach as follows:
create an injection token:
export const user_options = new injectiontoken<myconfig>('user_options');
provide the token in your library module
static forroot(config: myconfig): modulewithproviders {
return {
ngmodule: httptrackerlibmodule,
providers: [{
provide: user_options,
usevalue: config
}],
};
}
- use the token using di elsewhere:
export class configservice {
constructor(@inject(user_options) private _config: myconfig) {
}
}
Source: stackoverflow.com
Related Query
- How to get rid of Function calls are not supported in decorators in Angular aot compiling?
- Calling function 'ChartModule', function calls not supported
- how to get chart object inside a point event function in Highcharts
- how to use highcharts-angular callback function to get chart object
- How to get the Div id of charts in highcharts on click of it in angular 6
- using angular directive to draw highchart pie chart but when i am using it in success function it is not working
- How do I make the label in polar chart not get split automatically?
- How to get rid of the line labels in highcharts?
- TypeError: p is not a function while calling map function in angular 4 for fetching series for bellcurve highchart
- Function not working from particular context in angular
- How to get the angular component class reference inside an emitted Highcharts selection event callback function?
- How to get region/province code from IP address
- How to call a JS function every 10 sec which then activates a function in angular
- how to get updated value of react useState hook from setInterval function in highcharts?
- not able to get refs on addEventListener callback function
- Dynamically adding series, how to get rid of default y-axis?
- How can I get HighCharts column chart to scale the yAxis to not have so much whitespace?
- chartOptions.redraw is not a function in highcharts using angular
- Angular Module Is not a function - Highcharts-ng appearing on .aspx web form
- How to get the array format to function on x axis labels?
- How to get rid of 0 in X-axis
- How can I make some events are clickable or others not in Timeline Highchart?
- Decimals on yAxis are not being displayed, even if that same code works on highcharts jsfiddle
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- Scatter plot: How to get the name of the series into a function
- HighCharts pie chart X-axies values are not displayed while trying to get data from MySQL database using PHP
- Highchart tooltip formatter function not able to get x value (this.x)?
- How to remove Series name on bottom and we are not getting bar value on top of each bar and also each bar description is aligned cross in Columnchart
- How to get rid of highcharts 13 error in angular?
More Query from same tag
- Highchart is not define error while deploying on server
- Unable to programmatically toggle (close only) Highchart's default Context Menu using jQuery.toggle()
- How to set marginLeft and marginRight in HighCharts5
- Highcharts legend spread out to full width
- Highcharts. Series have same color after drilldown
- Zoom function breaks the xAxis labels and creates chart gaps when exiting zoom
- Issue on Switching Highcharts.js Spider Web Chart and Column Chart
- Highcharts copy HTML of chart can't disable cursor change
- How to fade other yAxises in highchart when hover on marker?
- Dates on xaxis with highcharts
- How add months as a x-axis to stock chart/ high charts
- Spline chart does not overlap with arearange chart (Highcharts framework)
- How to animate a HighChart chart that is created dynamically?
- How to set High charts series with X and Y value from mysql database
- How to create 2 axis and 2 yaxis in highchart
- HIGHCHARTS - Value of Columns Based on previous Column Value
- Displaying array values in Bar chart of HighCharts
- Join regions highmaps
- why my label formatter is not working as expected in highcharts
- Highcharts : trouble with axis Label
- Highcharts: Solidgauge Shadows
- Highchart data based to set div width and height dynamically
- Change Color of Highmap Areas based on database values
- How to show first and last date ticks in the navigator - Highcharts?
- Date type xAxis in Angular Highcharts is still allowing duplicate 'Date' values
- Creating a line graph with highcharts and data in an external csv
- Highcharts Click Function Not Being Called?
- Highcharts - How to format yAxis label to have single digit?
- Highcharts if title contains number it shows invalid data
- Highcharts - async drill-down in tree-map with thousands of items