From 6cc8fdd77f3c06bea0f8955873be22f07830e7c1 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 14 Nov 2014 14:53:28 -0600 Subject: [PATCH] docs(navView): update caching docs --- js/angular/directive/navView.js | 64 ++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/js/angular/directive/navView.js b/js/angular/directive/navView.js index d794b35c3b..12dd4051c8 100644 --- a/js/angular/directive/navView.js +++ b/js/angular/directive/navView.js @@ -70,35 +70,56 @@ * This is good to do because the template will be cached for very fast loading, instead of * having to fetch them from the network. * - *## Caching + * ## Caching * - *Caching can disabled/enabled by multiple ways. By default, Ionic will cache a maximum of 10 views. - *You could choose to disable caching through `$stateProvider.state`. + * By default 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 cycle. When navigating + * to a view which is already cached, its scope is then reconnected, and the existing element which + * was left in the DOM becomes the active view. This also allows for scroll position of previous + * views to be maintained. * - *``` - *$stateProvider.state('myState', { - * cache: false, - * url : '/myUrl', - * abstract: true, - * cache: true, - * templateUrl : 'my-template.html' - *}) - *``` + * Caching can be disabled and enabled in multiple ways. By default, Ionic will cache a maximum + * of 10 views, and not only can this be configured, but apps can also explicitly state + * which views should and should not be cached. * - *If you wish to disable caching globally in an app, you can edit the `$ionicConfigProvider.views.maxCache` + * Note that because we are caching these views, we aren’t destroying scopes. Instead, scopes are + * being disconnected from the watch cycle. Because scopes are not being destroyed and recreated, + * then controllers are not loading again on a subsequent viewing. If the app/controller needs to + * know when a view has entered or has left, then view events emitted from the + * {@link ionic.directive:ionView} scope, such as `$ionicView.afterEnter`, may be useful. * - *``` - *$ionicConfigProvider.views.maxCache(0); - *``` + * #### Disable cache globally * - *In this instance we’re setting the number of cached views to 0, essentially disabling the caching functionality. + * The {@link ionic.provider:$ionicConfigProvider} can be used to set the maximum allowable views + * which can be cached, but this can also be use to disable all caching by setting it to 0. * - *Note that because we are caching these views, we aren’t destroying scopes. Instead, scopes are being disconnected. - *Then when you travel back to that cached view, the scopes get reconnected. + * ``` + * $ionicConfigProvider.views.maxCache(0); + * ``` * + * #### Disable cache within state provider + * + * ``` + * $stateProvider.state('myState', { + * cache: false, + * url : '/myUrl', + * templateUrl : 'my-template.html' + * }) + * ``` + * + * #### Disable cache with an attribute + * + * ``` + * + * ... + * + * ``` + * + * + * ## AngularUI Router * * Please visit [AngularUI Router's docs](https://github.com/angular-ui/ui-router/wiki) for - * more info. Below is a great video by the AngularUI Router guys that may help to explain + * more info. Below is a great video by the AngularUI Router team that may help to explain * how it all works: * *