Javascript 在URL中隐藏参数值(guid)

Javascript 在URL中隐藏参数值(guid),javascript,angularjs,angular-routing,Javascript,Angularjs,Angular Routing,在我的路线上 .when('/user:user_guid',{ templateUrl : 'users/profile.html', controller : 'userController' }) 在我的index.html中的ng repeat中,我有 <a href="#/user/:{{user.user_guid}}">view profile</a> 它可以工作,但在我的URL中,我看到guid已经公开。有什

在我的路线上

.when('/user:user_guid',{
        templateUrl : 'users/profile.html',
        controller : 'userController'
    })
在我的
index.html
中的
ng repeat
中,我有

<a href="#/user/:{{user.user_guid}}">view profile</a>

它可以工作,但在我的URL中,我看到guid已经公开。有什么办法隐藏它吗?

使用

若您不想在浏览器中公开URL,请使用可在其中保存guid变量的服务,并在用户导航到
/user


这是演示

angular.module('demo',['ngRoute']);
角度.module('demo').config(函数($routeProvider){
$routeProvider
.当(“/欢迎”{
templateUrl:“欢迎使用页面”
})
.when(“/user”{
templateUrl:“你好页面”
})
。否则({重定向到:'/welcome'});
});
angular.module('demo').service('SecretServ',function(){
this.secret_guid='';
});
角度.module('demo').controller('Controller1',function($scope,$location,SecretServ){
$scope.user={
guid:'123345567234'
};
$scope.go=函数(){
SecretServ.secret\u guid=$scope.user.guid;
$location.path('/user');
};
});
角度.module('demo').controller('Controller2',函数($scope,SecretServ,$location){
$scope.guid=SecretServ.secret\u guid;
$scope.exit=函数(){
$location.path('/welcome');
}
});

我的应用程序
欢迎
要转到私人页面,请单击我 你好{{guid}},退出
您可以加密URL参数。然后在PHP中,当您读取POST/GET参数时,首先对其进行解密,然后读取值。这样就不会暴露任何东西。我已经为我自己的一些项目做过了,而且很有效

使用.when('/user:user\u guid',它仍然公开guid。我尝试删除它,只使用when('/user',它不起作用。你更新了你的答案吗?我看到了同样的情况。@AliceXu添加了演示,checkoutAh我想我现在明白了。必须初始化this.secret\u guid='';?如果我只返回这个.secret\u guid怎么办?那么,你想隐藏它的原始问题是什么?这是我的配置文件的url-其中有一个id,并且这根本不是问题。
<a ng-click="go_url(user)">view profile</a>
//it has many possible solutions, this is one of them
//according to your config, you're using angular route provider
$scope.go_url = function(_user){
    //be sure to inject $location service
    $location.path('/user/' + _user.user_guid);
}