|
37 | 37 | * - `{void}` `removeAll()` — Removes all cached values.
|
38 | 38 | * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory.
|
39 | 39 | *
|
| 40 | + * @example |
| 41 | + <example module="cacheExampleApp"> |
| 42 | + <file name="index.html"> |
| 43 | + <div ng-controller="CacheController"> |
| 44 | + <input ng-model="newCacheKey" placeholder="Key"> |
| 45 | + <input ng-model="newCacheValue" placeholder="Value"> |
| 46 | + <button ng-click="put(newCacheKey, newCacheValue)">Cache</button> |
| 47 | +
|
| 48 | + <p ng-if="keys.length">Cached Values</p> |
| 49 | + <div ng-repeat="key in keys"> |
| 50 | + <span ng-bind="key"></span> |
| 51 | + <span>: </span> |
| 52 | + <b ng-bind="cache.get(key)"></b> |
| 53 | + </div> |
| 54 | +
|
| 55 | + <p>Cache Info</p> |
| 56 | + <div ng-repeat="(key, value) in cache.info()"> |
| 57 | + <span ng-bind="key"></span> |
| 58 | + <span>: </span> |
| 59 | + <b ng-bind="value"></b> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </file> |
| 63 | + <file name="script.js"> |
| 64 | + angular.module('cacheExampleApp', []). |
| 65 | + controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) { |
| 66 | + $scope.keys = []; |
| 67 | + $scope.cache = $cacheFactory('cacheId'); |
| 68 | + $scope.put = function(key, value) { |
| 69 | + $scope.cache.put(key, value); |
| 70 | + $scope.keys.push(key); |
| 71 | + }; |
| 72 | + }]); |
| 73 | + </file> |
| 74 | + <file name="style.css"> |
| 75 | + p { |
| 76 | + margin: 10px 0 3px; |
| 77 | + } |
| 78 | + </file> |
| 79 | + </example> |
40 | 80 | */
|
41 | 81 | function $CacheFactoryProvider() {
|
42 | 82 |
|
|
0 commit comments