docs(ionicCaching): enabling/disabling caching of views

This commit is contained in:
mhartington
2014-11-14 15:02:54 -05:00
parent 94c6b42b02
commit 35b145bba6
2 changed files with 61 additions and 0 deletions

View File

@@ -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 were setting the number of cached views to 0, essentially disabling the caching functionality.
*
*Note that because we are caching these views, we arent 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:

View File

@@ -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
*<ion-view cache-view="false" view-title="My Title"></ion-view>
*```
*
*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 were setting the number of cached views to 0, essentially disabling the caching functionality.
*
*Note that because we are caching these views, we arent 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