search

Home  >  Q&A  >  body text

angular.js - angular 中如何实现多页面localStorage的共用?

现在项目中有一个撒花功能,因为表单提交是分多个页面跳转选项的,我想设置一个localstorage可以多个页面共用,且记录当前的表单的value值。

習慣沉默習慣沉默2745 days ago597

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-05-15 17:05:56

    localStorage is inherently global and can be used anywhere, without having to consider multiple pages. The method above is very standard! !

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-15 17:05:56

    Set a parent route for the form and bind the shared data model to the parent route.

    If you use localstorage, just record it and jump to it, and also save an object

    localStorage.setItem('key', JSON.stringify(obj));
    localStorage.getItem('key', JSON.parse(obj));

    reply
    0
  • Cancelreply