mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
docs(ionicCaching): enabling/disabling caching of views
This commit is contained in:
27
js/angular/directive/navView.js
vendored
27
js/angular/directive/navView.js
vendored
@@ -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:
|
||||
|
||||
34
js/angular/directive/view.js
vendored
34
js/angular/directive/view.js
vendored
@@ -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 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
|
||||
|
||||
Reference in New Issue
Block a user