From b136b162e606c7d969301ecdeda92b1c03d7f5f4 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 17 Nov 2014 14:28:56 -0600 Subject: [PATCH] docs(view): view lifecycle and events --- js/angular/directive/view.js | 20 ++++++++++++++------ js/angular/service/viewSwitcher.js | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/js/angular/directive/view.js b/js/angular/directive/view.js index ed3eca5e89..8cae983a5a 100644 --- a/js/angular/directive/view.js +++ b/js/angular/directive/view.js @@ -33,18 +33,26 @@ * * ``` * - * ## Events + * ## View LifeCycle and Events * * Views can be cached which means controllers may only load once, which could change how you'd - * expected data to load. To know when a view has entered or left, events have been added that + * expect controllers to fire. To know when a view has entered or left, events have been added that * get emitted from the view's scope. These events also contain data about the view, * such as the title and if the back button should show, along with transition data, such as the * transition type and direction that will be or was used. * - * * `$ionicView.beforeEnter` - * * `$ionicView.beforeLeave` - * * `$ionicView.afterEnter` - * * `$ionicView.afterLeave` + * * `$ionicView.loaded`: The view has loaded. This event only happens once per the scope being created + * and view element added to the DOM. If a view leaves and is cached, then a subsequent time it enters + * this this event will not fire again, rather it would only fire again if the view was not cached + * and accessed again. This is good place to put your setup code for the View. + * * `$ionicView.enter`: The view has fully entered and is now the active view. This event will fire + * no matter if it was the first load or it was a cached view. + * * `$ionicView.leave`: The view has finished leaving and is no longer the active view. This event will + * fire no matter if it will be cached or destroyed. + * * `$ionicView.beforeEnter`: The view is about to enter and become the active view. + * * `$ionicView.beforeLeave`: The view is about to leave and no longer be the active view. + * * `$ionicView.afterEnter`: The view has fully entered and is now the active view. + * * `$ionicView.afterLeave`: The view has finished leaving and is no longer the active view. * *## Caching * diff --git a/js/angular/service/viewSwitcher.js b/js/angular/service/viewSwitcher.js index b83e24fbb1..bbafcace12 100644 --- a/js/angular/service/viewSwitcher.js +++ b/js/angular/service/viewSwitcher.js @@ -64,7 +64,7 @@ function($timeout, $compile, $controller, $document, $ionicClickBlock, $ionicCon direction: direction, shouldAnimate: (transition !== 'none' && direction !== 'none'), showBack: !!showBack - }) + }); } function getViewData(view) {