In my Angular component, I have 4 fields: customerName
, startDate
, and startTime
. Additionally, I have a fourth field that is a textarea
where the user can see the message that will be sent via email or SMS. Within my component, I have defined a string as follows:
emailContent = 'Hi [customer_name],↵↵Your appointment has been scheduled for [start_date] at [start_time]'
Upon loading the component, I generate a message by replacing all text within the square brackets []
with the respective values of the input fields. For example, [customer_name]
is replaced with the value of customerName
, and so on. The resulting template looks like this:
Hi John Doe,
Your appointment has been scheduled for 30-Mar-20 at 03:00 pm.
Please confirm your appointment.
This template is visible in a textarea field, allowing the user to view and modify the text. If the user adds additional text in the textarea like this:
Hi John Doe,
Your appointment has been scheduled for 30-Mar-20 at 03:00 pm.
Please confirm your appointment. Please be on time there
The added text ("Please be on time there") needs to be parsed back into the tags format, like so:
'Hi [customer_name],↵↵Your appointment has been scheduled for [start_date] at [start_time]. Please be on time there'
I am looking for a way to extract that additional text entered by the user in the textarea
in Angular.