是什么$ ionicView.enter和缓存之间的区别:假的 [英] What is the difference between $ionicView.enter and cache:false

查看:687
本文介绍了是什么$ ionicView.enter和缓存之间的区别:假的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发需要调用倍数web服务的方法,每次视图打开,我应该使用时间视图 $范围。在$('$ ionicView.enter',函数(){ ...})缓存:假

I'm developing a view that need call multiples methods of a webservice every time the view is opened, should i use $scope.$on('$ionicView.enter', function(){...}) or cache:false ?

什么是每个人的真正区别?

What is the real difference between each one?

推荐答案

我真的很喜欢这个Q&放大器;答:

I really enjoyed this Q & A:

比拼班达里很好地总结中,我们有选择具有离子缓存机制

Where the Bipin Bhandari nicely summarizes the options we have with ionic caching mechanism


  1. 避免缓存由缓存:假

  2. $ ionicConfigProvider.views.maxCache(0)禁用缓存;

  3. 或保留缓存的是,让控制器只执行一次......虽然这些查看过程中做一些聪明的东西生命周期和活动

  1. avoid caching by cache: false,
  2. disable caching with $ionicConfigProvider.views.maxCache(0);
  3. or keep caching as is, and let controller be executed only once ... while doing some smart stuff during these View LifeCycle and Events

所以,用到位缓存,控制器将只执行一次:

So, with caching in place, controller will be executed just once:

视图被缓存以提高性能。当视图导航离开,它的元素被留在DOM,其范围从$观察周期断开。当导航到已缓存的图,其范围重新连接,而现有的元件,将其留在DOM,再次变为活动

Views are cached to improve performance. When a view is navigated away from, its element is left in the DOM, and its scope is disconnected from the $watch cycle. When navigating to a view that is already cached, its scope is reconnected, and the existing element, which was left in the DOM, becomes active again.

我们可以在这些事件挂钩......做一些永远的东西这个控制器

We can hook on these events... to do some "always stuff" with this controller

这篇关于是什么$ ionicView.enter和缓存之间的区别:假的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆