Include external functions


What is the cleaner way to include an old-style js functions file ?

I just want to import this file, and don’t really care about namespace for the moment.

Thx !

U can add <script> with src inside o index.html or(whic is better) use gulp(grunt) for this where you can concat all js files in one.

I have tried this way, but I only obtain a 404.

I think ionic serve dont package my file.

You can create a folder inside www called “js” and put your js files there. Then in index.html you can just add in the head section:

<script type="text/javascript" src="js/myFile.js"></script>

Although I don’t think this is a good practice.

###Thx !

It’s working !

If it’s a bad practice, is there any cleaner way to include this kind of file ?

I think you shouldn’t even have this kind of old-style js, it should be written as a class and then imported where necessary. But I think the experts can help you better here, for me this kind of old-style js doesn’t fit in ionic2 (although I’m using it myself :stuck_out_tongue: )

Ok, thanks a lot for explanations !

I try to do what you said but the function is not defined and i want to try the gulp but i don’t know how to do it can you teach me … beginner here


describe a more precise, what you wanna do and what does not work. The thread you refer is quite old.

Best regards, anna-liebt