search

Home  >  Q&A  >  body text

angular.js - Problem with angular page jumping and passing parameters?

I need to save the data obtained from the background in a model on the home page and then transfer it to subsequent web pages to use the data in this model. I've read a lot of information but still don't understand the parameter passing in ui-router. Can anyone write a demo example for me to see?

ringa_leeringa_lee2784 days ago520

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:10:58

    Save this value with a service

    reply
    0
  • 黄舟

    黄舟2017-05-15 17:10:58

    There are N ways to pass parameters. There may be mistakes in typing by hand. Please forgive me.

    1.ui-router

    路由配置
    $stateRouter.state('first.second',{
        url:'first/second/:type/:id', //传type参数和id参数,可以用url显示传,也可以调用$state.go()传。
        templateUrl:'tempUrl',
        params //这个也可以传参,不在url显示
    })

    2.service

    写一个service,service是单例的,a页面存数据,b页面获取数据,代码简单就不写了。

    3.localStorge, cookie

    html5支持的本地存储,类似cookie,但是比cookie存的数据要多。刷新也还会有。
    直接调用windows.localStorge就可以了。

    ...

    reply
    0
  • Cancelreply