angularjs - 如何将 AngularJS 响应传递给 window.url
问题描述
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){
$http({
method: 'POST',
url: '../api/CreateOrder',
data: Object.toparams(myobject),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response) {
window.location.href = "checkout.html?OrderId=" + response.data;
}, function errorCallback(response) {
alert("Error. while updating user Try Again!");
});
});
这是我的代码,我正在接收来自 http GET 的响应,如何将具有 OrderId 的响应数据作为参数传输到 window.location.href?
解决方案
response.data
让我们假设[{OrderId : 25 }]
然后尝试
window.location.href = "checkout.html?OrderId=" + response.data[0].OrderId;
推荐阅读
- javascript - 有人可以帮我定位带有链接的 ng-contents 吗?
- angular - 提交反应形式的动态值
- html - 证明内容块引导程序 4
- c# - 如何添加多个本机添加UWP的实例?
- android - 使用 Kotlin 默认值的 Jackson 反序列化失败
- sql-server - 从 CSV 读取的带小数点的潜在数据丢失
- javascript - 通过 NodeJS 和 SailsJS 下载文件
- javascript - 有没有办法从加载的内容中包含 OG 标签?
- javascript - ajax 成功后,Laravel 将数据附加到 $cList
- php - 如何在codeigniter中使用php加密保存在数据库中的数据