Ionic view lifecycle
来源:互联网 发布:数据科学家职业规划 编辑:程序博客网 时间:2024/06/16 11:13
To improve performance, Ionic developers have implemented and improved ability to cache view elements and scope data. With enabled caching, once initialized, a controller will persist throughout the app’s life, even if it’s hidden and removed from the watch cycle. Since the scope already exists, events were added for which we should listen when entering the watch cycle again.
These events can be used as an excellent tool if you want to trigger a piece of code during the view (re)initialization.
LOADED
At this point, the view is loaded into the DOM. This event will only happen once per view being created. If a view is cached but not active, this event will not fire again on a subsequent viewing.
This state is an excellent step if you want to initiate app configurations or anything that’s required to trigger only once ( the view must be cached).
$ionicView.loaded$scope.$on('$ionicView.loaded', function(){ // Anything you can think of});
ENTER
At this point, a view is active. This event will trigger, no matter it was the first load or a cached view.
This state is an excellent step if you want to do something every time view is active.
$scope.$on('$ionicView.enter', function(){ // Anything you can think of});
LEAVE
At this point, a view is no longer active. This event will trigger, no matter if it was the first load or a cached view.
Opposite to the enter event, This one is an excellent step if you want to do something every time view is nonactive (cached) or destroyed.
$scope.$on('$ionicView.leave', function(){ // Anything you can think of});
BEFOREENTER
This event will trigger when the view is about to enter and become the active view.
$scope.$on('$ionicView.beforeEnter', function(){ // Anything you can think of});
AFTERENTER
This event will trigger when the view has fully entered and is now the active view.
$scope.$on('$ionicView.afterEnter', function(){ // Anything you can think of});
BEFORELEAVE
his event will trigger when the view is about to leave and no longer be the active view.
$scope.$on('$ionicView.beforeLeave', function(){ // Anything you can think of});
AFTERLEAVE
This event will trigger when the view has finished leaving and is no longer the active view.
$scope.$on('$ionicView.afterLeave', function(){ // Anything you can think of});
UNLOADED
The view’s controller has been destroyed including its DOM elements.
This is an excellent point if you want to persist view data before it’s destroyed.
$scope.$on('$ionicView.unloaded', function(){ // Anything you can think of});
First time view initialization
1. View 1 – loaded
2. View 1 – beforeEnter
3. View 1 – enter
4. View 1 – afterEnter
Transaction from one view to another
1. View 2 – loaded
2. View 2 – beforeEnter
3. View 1 – beforeLeave
4. View 2 – enter
5. View 1 – leave
6. View 2 – afterEnter
7. View 1 – afterLeave
- Ionic view lifecycle
- Application & View lifecycle
- View Controller Lifecycle
- iOS中的View Controller Lifecycle
- Ionic view 生命周期
- request processing lifecycle phase1 restore view
- IOS开发之界面生命周期(view lifecycle)
- lifecycle
- LifeCycle
- Lifecycle
- ionic 中的传参 跳转 及表单的使用方法 以及生命周期(lifecycle) 和滚动ionScroll
- Ionic Js十二:导航ion-nav-view
- Ionic ion-nav-view使用整理
- ionic---ion-view 视图的生命周期
- Ionic
- ionic
- Ionic
- Ionic
- 数字图像处理入门
- Java的Date格式的应用
- C语言实现简单的日志封装
- Caffe源码阅读(1) 全连接层
- 第十七周项目C 结构体--学生信息排序
- Ionic view lifecycle
- matlab函数 bwperim
- Linux C语言连接MySQL 增删改查操作
- 插件记录
- Java的内存机制(堆和栈)简单理解
- 进口信用证项下的贸易融资——提货担保
- 2016.12.19 学习日记-工厂方法模式
- [bzoj4237]稻草人
- 如何使用php session