刷新浏览器后如何保持$ stateparams参数 [英] How to keep $stateparams parameters after i refresh the browser

查看:849
本文介绍了刷新浏览器后如何保持$ stateparams参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个用户列表..当用户点击列表中的其中一个用户时...它会将我重定向到我的profileState以及用户的相关UID。我使用状态参数将UID从userListState传递给profileState ..
当我输入

I have this list of users .. When a user clicks in one of those user in the list.. it will redirect me to my profileState with the associated UID of the user. I use state parameters to pass the UID from the userListState to the profileState.. When i type

console.log($stateParams);

它显示我从userListState传递的UID ..但是一旦我刷新页面.. UID将变为null ..所以我想知道你们如何在页面重新加载后使特定数据保留在那里。

it displays the UID which i passed from userListState .. but once i refresh the page.. the UID will become null.. So i would like to know how you guys make that specific data remain there after page reload.

推荐答案

你配置了你的州吗?因为你应该做点什么

How do you have configured your states? becuase you should do something like

.state('app.profile', {
    url: '/profile/:uid',
    views: {
        '@app': {
            templateUrl: 'app/profile/index.html',
            controller: 'ProfileController as profileCtrl'
        }
    },
    params: {
        uid: null
    }
})

这种方式当你去你的州时你最终会得到
localhost / profile / 234

this way when you go to your state you'll end up with localhost/profile/234

你会刷新,uid会在那里。

you will refresh and uid will be there.

这篇关于刷新浏览器后如何保持$ stateparams参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆