Issue
I would like to personalize an email with different variables, that is, select a word and add a certain character such as: $, {}, [] to know that it is a variable, something like this: {name} I would like to know if there is any plugin for Angular 14+ that could help me in this case. I attach an example that I saw on www.courier...
Solution
you can play with regExpr, e.g.
data={'one':'Dolly','two':'a sheep'}
message="Hello {one} I'm {two}"
message2=this.parseMessage(message)
parseMessage(message:string){
Object.keys(this.data).forEach(key=>{
const regexp=new RegExp('\\{'+key+'\\}','gi')
message=message.replace(regexp,this.data[key])
})
return message
}
Answered By - Eliseo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.