angular.js - Problem with angular page jumping and passing parameters?
ringa_lee
ringa_lee 2017-05-15 17:08:58
0
2
532

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_lee
ringa_lee

ringa_lee

reply all(2)
Ty80

Save this value with a service

黄舟

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就可以了。

...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template