javascript – $ionView.enter和cache之间有什么区别:false

我正在开发一个视图,每次打开视图时都需要调用多个webservice方法,我应该使用$scope.$on(‘$ionView.enter’,function(){…})或cache:false ?

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

解决方法

我真的很喜欢这个问答A:

ui.router not reloading controller

Bipin Bhandari很好地总结了离子缓存机制的选择

>避免缓存缓存:false,
>使用$ionConfigProvider.views.maxCache(0)禁用缓存;
>或者保持缓存的状态,并让控制器只执行一次,而在这View LifeCycle and Events期间做一些聪明的事情

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

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.

我们可以挂钩这些事件…做这些控制器的“总是东西”

相关文章

什么是深拷贝与浅拷贝?深拷贝与浅拷贝是js中处理对象或数据...
前言 今天复习了一些前端算法题,写到一两道比较有意思的题:...
最近在看回JavaScript的面试题,this 指向问题是入坑前端必须...
js如何实现弹出form提交表单?(图文+视频)
js怎么获取复选框选中的值
js如何实现倒计时跳转页面