As import ionic.native.js in Ionic V1 / Angular 1.x

Now it becomes difficult to see documents or examples when Ionic 2 is missing.

I want to use ionic.native.js in the old project Ionic V1. The fact that the installation is carried out using npm

npm install ionic-native --save

But now I have a ton of npm modules under node_modules/ as a dependency. Ion documentation says:

If you are using Angular 1.x or plain ES5 JavaScript, you need to add to your index.html ionic.native.js

but they do not give an example of "how" to place it in index.html - and this is my question.

Currently my file is located in:

 > find . -name ionic.native.js ./node_modules/ionic-native/dist/ionic.native.js 

No problem for gulp node_modules/ the dir ... so how do I import it into index.html ? or maybe I used the npm command in the wrong place? (now it is in the root directory of the project, where gulpfile.js lives)

+5
source share
4 answers

I had the same problem as you.

In the end, what ultimately decided to use it:

 bower install ionic-native --save 

This adds the files to the lib / directory, which is accessible from the index page.

Then, in the index.html file, add:

 <script src="lib/ionic-native/ionic.native.js"></script> 

Hope this helps!

+5
source

Copy ionic.native.js in folder js , and add a <script src="js/ionic.native.js"></script> "> </ script> in your index.html

0
source

I was also upset by this. In the end, I just copied the ionic.native.js file into the lib folder and imported it like this:

<script src="lib/ionic.native.js"></script>

It worked, but I'm worried it will now be a hassle to deal with this and its dependencies.

0
source

If you want to use npm instead bower , you can add the path to the right place when you install the plugin:

 npm install ionic-native --save --prefix www/lib 
0
source

All Articles