Subho
Subho

Reputation: 923

how to include a external js file in Angular2

I am new to Angular2. I need to add Google map library in one page and in another page fusion chart library. One thing I can do is to add all those in index.html where my all the pages will show. But I want to add libraries in particular pages. How to add libraries in particular page partials?

Upvotes: 1

Views: 251

Answers (1)

FAISAL
FAISAL

Reputation: 34673

In your terminal window, locate to your project directory, where package.json is placed. Then run the following command to install fusion-charts:

npm install angular2-fusioncharts --save-dev

To include that in a your app, add the following in your AppModule:

// Import angular2-fusioncharts
import { FusionChartsModule } from 'angular2-fusioncharts';

// Import FusionCharts library
import * as FusionCharts from 'fusioncharts';

Now you can use fusion-charts throughout your app. You dont have to add any link in your index.html. You can do the same for using google-maps (getting started guide).

Here is a link to angular2-fusioncharts github repository.

Upvotes: 2

Related Questions