urish / angular-load

Dynamically load scripts and css stylesheets in your Angular.JS app
MIT License
243 stars 65 forks source link

several scripts or css #12

Open vptcnt opened 9 years ago

vptcnt commented 9 years ago

Hi

is it possible to chain several loads of scripts or cas ?

gang-qiu commented 9 years ago
evilaliv3 commented 9 years ago

@vptcnt / : @kevin-qiu: given that loadScript() and loadCSS() both returns a promise you could chain one promise to the other or even make a wrapping functioin that given a list of resources make this for you.

by the way @urish i agree that this would be an interesting feature; loadCSS and loadJS may accept also an array of resources and return a promise that will fire whenever all resources are fetched.

jsdw commented 8 years ago

Promises make this very easy, So I'm not sure I'd duplicate this functionality in the library:

$q.all([
    angularLoad.loadScript('https://mysite.com/someplugin1.js'),     
    angularLoad.loadScript('https://mysite.com/someplugin2.js')
]).then( reactToAllScriptsBeingLoaded )