Reuse an AngularJS template between page views for the same route

空扰寡人 提交于 2019-12-06 09:28:22

This is a non-trivial problem.

The angular-gm module reuses map instances so there is no memory leak. There is also angular-google-maps.

kfis

I do it with the help of the routeproviderapi

http://docs.angularjs.org/api/ng.$routeProvider

You have the opportunity to have a resolver, that resolves all dependencies, that your controller needs for rendering the template. My resolover caches the object for the specific routeparams and will return this already instantiated object.

So basically your map-object is a dependency of your controller. The resolver manages the injection of this dependency and there you can implement some caching.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!