Several ways to pass parameters across pages in a ionic project

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.