【发布时间】:2018-05-17 08:04:59
【问题描述】:
我正在尝试发送一封电子邮件,正文中的链接包含从 Firebase 检索到的值。我已成功检索该值,但我不知道如何将其附加到已列出的链接中。 代码如下:
sendinvite() {
var user = firebase.auth().currentUser;
var uid = user.uid;
firebase.database().ref('/userlist/' + uid + '/' + 'hashKey').once('value').then(function(snapshot) {
var hashKey = (snapshot.val());
console.log(hashKey)
});
var bcc = [];
for(var e in this.emailinputs){
if (this.emailinputs[e].email==null || this.emailinputs[e].email=="" || !this.emailinputs[e].email.includes("@") || !this.emailinputs[e].email.includes("."))
{
let alert = this.alerCtrl.create({
title: 'Error!',
message: 'There was an error with an email address you entered.',
buttons: ['Ok']
});
alert.present()
}else {
bcc.push(this.emailinputs[e].email);
}
}
if(bcc.length > 0) {
let email = {
bcc: bcc,
subject: 'Nudget Invite',
body: '<a href="https://nudget-72ee4.firebaseapp.com/?hashkey='+hashKey+'">Join my grocery list!</a>',
isHtml: true
};
this.emailComposer.open(email);
}
}
我希望将变量 hashKey 附加到正文中列出的 URL,但我不确定如何实现。
编辑 1
更新了正文以将变量附加到字符串。我不确定我可以将 Firebase 中的 hashkey 放在哪里以便正确引用它。
【问题讨论】:
-
您是否尝试过使用标准查询字符串?例如:
https://nudget-72ee4.firebaseapp.com/?key=value -
@Tigger 我目前有
'<a href="https://nudget-72ee4.firebaseapp.com/?hashkey='+hashKey+'">Join my grocery list!</a>'。问题是我不知道在哪里可以放置 hashKey 变量以供引用。
标签: javascript typescript firebase