如何在ionic / angularjs中预取url? [英] How do I prefetch url's in ionic/angularjs?
问题描述
我对离子1很新,我正在开发一个带有多个URL的应用程序(带有Ionic 1和angular js),每个URL都会显示一个类别列表,然后是每个类别和每个项目的项目列表有一个文档URL。如何在后台启动时预加载所有这些URL但不显示它们?有什么办法可以实现吗?一个好的代码示例或教程将有很大帮助。
另外,请告诉我这是否是最好的方法,如在启动时预加载和预缓存所有内容,或者应该按类别或其他方式完成。
I am pretty new to ionic 1 and I am working on an application (with Ionic 1 and angular js) with multiple URLs where each URL brings up a list of categories, followed by a list of items for each category and each item has a document URL. How do I preload all these URLs on launch in the background but not display them?Is there any way this can be achieved? a good code sample or tutorial will help greatly. Also, please let me know if this will be the best approach, as in pre-loading and pre-caching all content upon launch or should it be done category by category or some other way.
提前致谢!
推荐答案
您可以制作多个异步服务使用 $ q在后台调用。
在数组中创建一个URL列表,并使用 $ q.all(listOfURL)立即调用它们)。
使用promises检索每个响应。
You can make multiple Asynchronous service calls in background using $q.
Make a list of URL's in an array and call them at once using $q.all(listOfURL).
Using promises retrieve each response.
通过使这种异步可以节省大量时间。
By making this asynchronous you can save lot of time.
获得回复后,您可以将它们存储在 $ rootScope
或 localStorage / sessionStorage。
After getting response you can either store them in $rootScope
or in localStorage/sessionStorage.
这篇关于如何在ionic / angularjs中预取url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!