Ionic 2 set up plugins

Hi All,

In Ionic 2, how do you set up bower_components? For example ngImgCrop is installed with:

bower install ngImgCrop

This sets up a bower_components folder with the ngImgCrop libraries.

app
bower_components
----------------ng-img-crop
www

I can find documentation on how to add the dependencies to an Ionic 1 app:

 <script src="angular.js"></script>
 <script src="ng-img-crop.js"></script>
 <link rel="stylesheet" type="text/css" href="ng-img-crop.css">

and

var myAppModule = angular.module('MyApp', ['ngImgCrop']);

Does anyone know how to configure this in an Ionic 2 app please? I think I need to add an import, but how does your import access the bower_components as they are outside the www folder, or should they be copied to a lib folder inside the www folder?

import { NgImgCrop } from '...';

Thanks

1 Like

bower is busted, but that’s the least of your problems. You aren’t going to be able to use an Angular1 library in an Angular2 application.

Thanks rapropos. You saved me going down the wrong path.

How about cordova-plugin-crop? Will that work with Ionic 2?

How do you do the import?

import { CropPlugin } from '';

Does the CropPlugin have to be added to the node_modules folder? I installed it like this:

$ cordova plugin add --save cordova-plugin-crop

But am not sure where to import the installed plugin from.

SOLVED

see Image cropping plugin