Javascript 所有集合的Firestore列表

Javascript 所有集合的Firestore列表,javascript,angular,firebase,google-cloud-firestore,angularfire2,Javascript,Angular,Firebase,Google Cloud Firestore,Angularfire2,我在数组中有一个json字段名列表,比如 eventVariables = ['customerName','date','amount']. 我的JSON看起来像 info = { 'customerName':'Ashish Maity', 'date': '14-04-18', 'amount':'500' } 现在我想向该客户发送消息,我的消息模板如下: smsBody = 'Dear customerName, we have received Rs.amount on date'

我在数组中有一个json字段名列表,比如

eventVariables = ['customerName','date','amount'].
我的JSON看起来像

info = {
'customerName':'Ashish Maity',
'date': '14-04-18',
'amount':'500'
}
现在我想向该客户发送消息,我的消息模板如下:

smsBody = 'Dear customerName, we have received Rs.amount on date';
现在我的要求是,我想用info JSON中的值替换smsBody中的变量(customerName、amount和date)

My code:
for(let i=0; i<eventVariables.length; i++){
 finalSmsBody = smsBody.replace(eventVariables[i],info[eventVariables[i]]);
};

My Output:
Dear customerName, we have received Rs.amount on 14-04-18
我的代码:
对于(设i=0;i

for (var key in info ){
   smsBody.replace(key,info[key])
}
试试这个代码

for(let i=0; i<eventVariables.length; i++){
  smsBody= smsBody.replace(eventVariables[i],info[eventVariables[i]]);
};

for(让我=0;标题提到了Firestore,您已经标记了Firestore,但问题并没有提到Firestore。这个问题实际上是关于Firestore和Firestore中的集合的吗?我的代码是否为您提供了答案?@ashish maity可以投票给这个答案,如果上述代码解决了您的问题