Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include javascript third party library in ionic app?

I am sorry to ask this silly question. I am trying to use pathfinding.js (https://github.com/qiao/PathFinding.js/) in ionic for my navigation.html page (a partial file located in the www/templates/ directory) but it's not working with partials files except with index.html root file only. However, it gives me error if I use it in the index.html root file, maybe because it needs to draw a svg in the navigation.html page, but it could not find the navigation.html page since it is in the index.html (dependency with the navigation.html)

I am thinking to use bower, but can bower solve this problem?

like image 239
Hardyanto Putra Antoni Avatar asked Jan 05 '17 05:01

Hardyanto Putra Antoni


People also ask

Can we use JavaScript in Ionic?

Building Hybrid Apps With Ionic At its core, it's just a web page running in an native app shell! That means we can use any kind of HTML, CSS, and Javascript we want.

How do I build an NPM Ionic library?

The first step to your own custom Ionic library is to generate an Angular library. But this library needs to live inside a workspace, so we generate a new workspace without any application first and then generate the library and add two more components to it.


1 Answers

In index file add the script tag to add scripts.

<script src="./templates/PathFinding.js/">`

It will get loaded.

However, if you use Bower.. Bower will only download the files to src folder .. then you need to manually add script tags for script into the index.html.

like image 146
Atul Sharma Avatar answered Nov 08 '22 11:11

Atul Sharma