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
There are N ways to pass parameters. There may be mistakes in typing by hand. Please forgive me.
路由配置
$stateRouter.state('first.second',{
url:'first/second/:type/:id', //傳type參數(shù)和id參數(shù),可以用url顯示傳,也可以調(diào)用$state.go()傳。
templateUrl:'tempUrl',
params //這個也可以傳參,不在url顯示
})
寫一個service,service是單例的,a頁面存數(shù)據(jù),b頁面獲取數(shù)據(jù),代碼簡單就不寫了。
html5支持的本地存儲,類似cookie,但是比cookie存的數(shù)據(jù)要多。刷新也還會有。
直接調(diào)用windows.localStorge就可以了。