javascript - 如何将值从角度方法传递给属性
问题描述
您好我正在尝试将值从方法传递给属性
这是我的代码
我想将 sub_id_1 传递给 subscription_id 下的选项
我正在尝试 3 天任何帮助,请
这是一个剃须刀集成我正在从 python 获取响应并以角度恢复它,但我认为我被锁定在 buy() 方法
public buy() {
return this.http.get("http://127.0.0.1:5000/razor_sub",{
}).subscribe(
(res)=>{
var rrre = res.json();
var sub_id_1 = rrre.id;
if (sub_id_1) {
console.log(sub_id_1);
const type = sub_id_1;
this.sub_response_id(sub_id_1)
}
});
}
/**
* sub_response_id
*/
public sub_response_id(sub_id_1) {
this.initPay(sub_id_1)
}
public options: any = {
key: 'rzp_test_******',
subscription_id: this.sub_response_id(sub_id_1),
name: "Acme Corp.",
description: "Monthly Test Plan",
image: "#",
handler: function(response) {
//alert(response.razorpay_payment_id),
//alert(response.razorpay_subscription_id),
//alert(response.razorpay_signature);
},
prefill: {
name: "Tamer Jarrar",
email: "tamerjrrar@example.com",
contact: "+919876543210"
},
notes: {
note_key_1: "Tea. Earl Grey. Hot",
note_key_2: "Make it so."
},
theme: {
color: "#F37254"
}
};
initPay(sub_id_1): void {
this.rzp = new this.winRef.nativeWindow['Razorpay'](this.options);
this.rzp.open();
}
paymentHandler(res: any) {
this.zone.run(() => {
});
}
解决方案
buy() {
return this.http
.get("http://127.0.0.1:5000/razor_sub", {} )
.subscribe(res => {
const { id } = res;
if (id) {
const options = getOptions(id);
this.initPay(options);
}
}
);
}
getOptions(subscription_id) {
return {
key: 'rzp_test_******',
subscription_id,
name: "Acme Corp.",
...
}
};
initPay(options) {
this.rzp = new this.winRef.nativeWindow['Razorpay'](options);
this.rzp.open();
}
那是你需要的吗?
推荐阅读
- jenkins - 无法通过通用方法登录时如何登录Jenkins
- maven - 使用 mvn flyway:migrate 的 Flyway 迁移给出“迁移 1.0.53 不匹配”错误
- kubernetes - 使用 terraform 向 EKS 节点添加标签
- react-native - 如何使用带有 React native 的 switch 更改应用程序的按钮颜色
- javascript - 在 React 中搜索时返回“未找到结果”状态
- html - 如何将本地 html 文件转换为包含 gif 图像的 pdf?
- node.js - 如何使用节点在 redis 中获取原始十六进制字符串值?
- android - 如何安装模拟器可执行文件 Visual Studio Android 模拟器
- jquery - 如何将粘贴事件支持添加到magicsuggest?
- json - 根据 Swift 中的最新日期使用 JSON 解码过滤数组中的字典