【发布时间】:2018-01-23 17:08:54
【问题描述】:
我有一个 index.php 页面,它执行 POST 请求。在发布请求之后,我创建了一个查询字符串
PHP 代码 sn-p : - index.php
// example url : /some-route?&email=test@abc.com&first_name=test
$url: "/some-route?&email=".trim($_POST["email"])."&first_name=" .
trim($_POST["firstName"]);
header('Location: '.$url);
这是指向 Angular js 路由文件
Angular js -> stateProviderfile -> states.js
$stateProvider
.state("some-route", {
url: '/some-route?isSomeApp',
templateUrl : 'app/components/application/some-
information/someView.html',
controller : 'someCtrl',
params: { isSomeApp: null},
data: { public: true }
});
现在我想检索 Query 参数中的值并将其存储在 $scope 变量中,以便我可以自动填充 someView.html 中的文本字段 我在 someCtrl.js 中使用的代码是:
enter code here
$scope.parse = function(){
if ($scope.params["first_name"] != undefined) {
$scope.firstname = $scope.params["first_name"];
}
if ($scope.params["email"] != undefined) {
$scope.email = $scope.params["email"];
}
}
// call the above function in init() in someCtrl.js
$scope.init = function(){
$scope.params = $location.search();
if (Object.keys($scope.params).length > 0) {
$scope.parseParams();
}
}
我的问题是:如何在 url 中隐藏 first_name 和 email,以便最终用户看不到它,但以某种方式拥有它,以便我可以访问它 someCtrl.js
我希望用户看到:/some-route
我的代码看到:示例网址:/some-route? &email=test@abc.com&first_name=test
我希望实际网址具有隐藏参数 email 和 first_name - 所以用户看不到这些信息并且 - 我可以从我的代码中访问它
我怎样才能做到这一点?
【问题讨论】:
-
您不能在 GET 调用中隐藏 URL 参数。您需要为此使用 POST 调用。
-
在这种情况下如何添加 post call?
标签: javascript php angularjs url uri