Answer the question
In order to leave comments, you need to log in
How to pass parameters to Map in Typescript?
There is a Map of the following form
export const events: Map<EventEnum, EventDo> = new Map([
[
EventEnum.SentItem,
{
text: '{{ username: link }} gave you {{ itemAmount }}x [{{ itemName }}].',
category: EventCategoryEnum.Friends,
},
],
[
EventEnum.StolenItem,
{
text: '{{ username: link }} attacked you and stole your {{ itemName }}.',
category: EventCategoryEnum.Attacks,
},
],
[
EventEnum.ContractDecline,
{
text: '{{ username: link }} has declined your contract. [{{ DETAILS: link }}]',
category: EventCategoryEnum.Commerce,
},
],
]);
this.events.forEach(element => {
element.text = events.get(element.id).text;
});
{{ username: link }} has declined your contract. [{{ DETAILS: link }}]
Answer the question
In order to leave comments, you need to log in
The very case when neither Map, nor TypeScript, nor Angular are directly related to the question.
Learn JavaScript. Specifically, work with strings and regular expressions. Just in case, ask one of your senior colleagues, perhaps the project uses a library to work with such patterns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question