zoukankan      html  css  js  c++  java
  • type $cacheFactory.Cache

    用于存储和检索数据的缓存对象,主要用于http和scipt指令,用于缓存模板和其他数据。

    用法:

    index.html

    <!DOCTYPE html>
    <html ng-app="indexApp">
    <head lang="en">
        <meta charset="UTF-8">
        <title>BookStore</title>
    </head>
    <body  ng-controller="firCtrl">
    <div>
        <label>msg:<input ng-model="msg" /></label>
        <label>id:<input ng-model="msg.id" /></label>
        <label>size:<input ng-model="msg.size" /></label>
    </div>
    <script src="framework/angular.js"></script>
    <script src="myJs/cache.js"></script>
    <script src="myJs/index.js"></script>
    </body>
    </html>

    index.js

    angular.module('indexApp',["superCache"])
        .controller('firCtrl',['$scope', 'smCache' ,function($scope, smCache){
            smCache.put("name","drr");
            smCache.put("how","like");
            $scope.msg = smCache.info();
    }]);

    cache.js

    angular.module('superCache',[])
    .factory('smCache',['$cacheFactory',function($cacheFactory){
        return $cacheFactory('ms');
    }]);

    方法:

    put(key, value);

    get(key);

    remove(key);

    remove(key);

    destroy();

    info(); 返回具有以下属性的对象:id:缓存实例的id,size::缓存实例中保存的条目的数量...在创建缓存时,选项对象中的任何其他属性。

  • 相关阅读:
    2019.8.15刷题统计
    2019.8.12刷题统计
    2019.8.11刷题统计
    2019.8.10刷题统计
    2019.8.9刷题统计
    2019.8.8刷题统计
    2019.8.7刷题统计
    2019.8.6刷题统计
    xuezhan.org 6.28
    xuezhan.org 6.27
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7027664.html
Copyright © 2011-2022 走看看