What is the recommended way to add third party library

Use Bower, it’s made for exactly this purpose.

I believe Ionic creates a bower.json for you if you’ve used the Ionic CLI to create your project. If not, just run bower init to get started.

Now you can install any package mentioned on Bower’s website by using bower install, similar to how NPM works.

For example, if you want to install Angular localForage you use: bower install angular-localforage --save.

Using --save will add it to your Bower.json, so if someone else checks out your project they’ll only have to run bower install to get all the project’s dependencies (again, just like NPM and its package.json.)

By default Bower will install everything to a folder called bower_components. You can change this by creating a .bowerrc file and specifying a directory value, like so:

{
  "directory": "www/lib"
}

Make sure to add the Bower directory to your .gitignore! The only things you should check in is your bower.json and .bowerrc files.

Hope this helps :slight_smile:

6 Likes