Marcos Batista
Marcos Batista

Reputation: 1

How do I import javascripts libraries into my application with Ionic 2?

How do I import javascripts libraries into my application with Ionic 2?

Some time ago I used Ionic 1 to develop hybrid applications, now I'm starting with Ionic 2, and from what I realized, it's only accepting npm's plugins. Example library I want to use: https://github.com/tsironis/lockr.

In Ionic 1 it was enough to import the script in the file index.html (<script src = "/path/to/lockr.js" type = "text/javascript"> </ script>).

Upvotes: 0

Views: 93

Answers (1)

DRiFTy
DRiFTy

Reputation: 11369

To bring in an external library, just install it via npm (be sure to use the --save parameter in case you blow away your node_modules folder at some point). Then all you need to do is add an import statement that references the module you want to include in any one of your files, and it will be brought in for you automatically.

Alternatively, you can still use <script> tags by editing the index.html file in the www directory of your project.

Upvotes: 1

Related Questions