From 35b145bba62e349ec59b88ab3660dbed139c3226 Mon Sep 17 00:00:00 2001 From: mhartington Date: Fri, 14 Nov 2014 15:02:54 -0500 Subject: [PATCH] docs(ionicCaching): enabling/disabling caching of views --- js/angular/directive/navView.js | 27 ++++++++++++++++++++++++++ js/angular/directive/view.js | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/js/angular/directive/navView.js b/js/angular/directive/navView.js index ee84d1fbb5..d794b35c3b 100644 --- a/js/angular/directive/navView.js +++ b/js/angular/directive/navView.js @@ -70,6 +70,33 @@ * 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 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`. + * + *``` + *$stateProvider.state('myState', { + * cache: false, + * url : '/myUrl', + * abstract: true, + * cache: true, + * templateUrl : 'my-template.html' + *}) + *``` + * + *If you wish to disable caching globally in an app, you can edit the `$ionicConfigProvider.views.maxCache` + * + *``` + *$ionicConfigProvider.views.maxCache(0); + *``` + * + *In this instance we’re setting the number of cached views to 0, essentially disabling the caching functionality. + * + *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. + * + * * 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 * how it all works: diff --git a/js/angular/directive/view.js b/js/angular/directive/view.js index f9b8a4f280..ed3eca5e89 100644 --- a/js/angular/directive/view.js +++ b/js/angular/directive/view.js @@ -46,6 +46,40 @@ * * `$ionicView.afterEnter` * * `$ionicView.afterLeave` * + *## Caching + * + *Caching can disabled/enabled by multiple ways. By default, Ionic will cache a maximum of 10 views. You can optionally choose to disable caching a view through the `cache-view` attribute directive. + * + *```html + * + *``` + * + *Alternatively, you could choose to disable caching through `$stateProvider.state`. + * + *``` + *$stateProvider.state('myState', { + * cache: false, + * url : '/myUrl', + * views: { + * 'nav-view': { + * templateUrl : 'my-template.html' + * } + * } + *}) + *``` + * + *If you wish to disable caching globally in an app, you can edit the `$ionicConfigProvider.views.maxCache` + * + *``` + *$ionicConfigProvider.views.maxCache(0); + *``` + * + *In this instance we’re setting the number of cached views to 0, essentially disabling the caching functionality. + * + *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. + * + * * @param {string=} view-title The title to display on the parent {@link ionic.directive:ionNavBar}. * @param {boolean=} cache-view If this view should be allowed to be cached or not. Default `true` * @param {boolean=} hide-back-button Whether to hide the back button on the parent