作用:不同的controller之间传递数据。
put(key, value);//添加
get(key);//获取
removeAll();//删除全部
remove('key')//删除某一项
destroy();//完全破坏Cache对象,将其从$cacheFactory集中删除
info();//检索有关特定缓存的信息。
var app = angular.module('test',[])
app.controller('testapp1',function ($scope,$cacheFactory) {
$scope.cache=$cacheFactory('cache1')
$scope.cache.put('1','abc');
$scope.cache.put('2','def');
$scope.name = $scope.cache.info();
console.log($scope.name)
})
app.controller('testapp2',function ($scope,$cacheFactory) {
$scope.cache = $cacheFactory.get('cache1');
$scope.name= $scope.cache.get('1');
console.log($scope.name);
})