How to load different library in different tabs?


#1

For example, if I have 3 tabs, with one tab showing map. I would like to have map related js library only in that tab. However if I put it in index.html it will be loaded no matter where I am. Any way to do this? Thanks.


#2

You should have a look into requirejs:
http://requirejs.org/

I am building my whole apps with requirejs to have a modular clean project structure for development.
(At the end i have a build script that minifies and combines everything in one js-file)

I have written a tutorial some time ago in german:
http://www.flyacts.com/blog/tutorial-angularjs-mit-requirejs/
http://www.flyacts.com/blog/tutorial-angularjs-mit-requirejs-und-ionic-framework/

But you have also the possibilty to load the ionic.bundle in your index.html before your requirejs config and only use require for your app parts and libs.


#3

Thank you so much. It looks quite complicated.