1, the use of Angularjs to bring their own $cachefactory services
$cacheFactory literal literal translation is the cache factory, which can be used to generate cache objects, cache objects in a key-value way of data storage
In the entire application is a singleton, you can inject the service or controller, and then you can use it to freely access objects and various variables, here is a simple example
function ($scope, $ionicModal, $timeout, $cacheFactory) { var user = {name: ' Jax ', age:18, Sex: ' Male '};
var user_cache = $cacheFactory ("User_cache"); // declaring a User_cache cache object User_cache.put ("LOL", user); //
. Controller (' Playlistctrl ', function ($ Scope, $stateParams, $cacheFactory) { var user_cache = $cacheFactory. G ET ("User_cache"); // var user = user_cache.get ("LOL"); // Remove objects in the cache object with a key value of LOL // user_cache.remove ("LOL"); Remove the value for lol corresponding to // User_cache.removeall () ; Clears all key-value pairs in the cached object // User_cache.destroy (); Destroys the User_cache cache object Console.log (user); });
Several ways to pass parameters across pages in a ionic project