2

I have created a new project using angular-cli I followed all the steps that are suggested at the page https://www.npmjs.com/package/angular2-highcharts

npm install angular2-highcharts --save import { ChartModule } from 'angular2-highcharts'; ChartModule.forRoot(require('highcharts')

When I run the app, it says cannot find name 'require' Do I need to follow any other steps.

indra257
  • 66
  • 3
  • 24
  • 50
  • You can a live example with the config of angular2 with highcharts http://embed.plnkr.co/IuwjpPB1YQW1T7i4B8SZ/ – morganfree Apr 03 '17 at 10:35
  • I'm having the same issue. Using system.config works fine (like in the example @morganfree linked to) but the second you try to aot compile with angular cli poop hits the fan and you can't execute a rollup. – cobolstinks Apr 12 '17 at 20:09
  • You can try following workaround for making it work for AOT rollup build https://davidsekar.com/angularjs/workaround-for-using-angular2-highcharts-with-aot-rollup-build – David Chelliah Apr 27 '17 at 15:44

1 Answers1

1

Try to add this dclaration on your component : declare var require: any;

I had the same problem. I didn't have much time to resolve the problem. So i used ng2-highchart (an alternative for angular2-highcharts).

-you can follow instruction for installation by there

-You will find the github project for more informations.

-With an example on Angular-Cli .

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Omar Bait
  • 11
  • 3