As a beginner in Angular and TypeScript, I am facing an issue with displaying the value of an input field (phone number) when sending an email to the admin. The code below is not working properly and I am getting an error during continuous integration. It says "Declaration of instance field not allowed after declaration of instance method. Instead, this should come at the beginning of the class/interface." Here is the updated code:
<div class="text-input">
<label i18n="@@phoneNumberTitle" for="phoneNumber">i18n</label>
<input
id="phoneNumber"
autocomplete="off"
placeholder="@@placeholderphoneNumberTitle"
i18n-placeholder="@@placeholderphoneNumberTitle"
name="phoneNumber"
#phoneNumber="ngModel"
[(ngModel)] = "phone_number"
required
/>
This is the TypeScript code:
/**
* Call service to send notification via email to admin
*/
phone_number:any;
sendEmailToNotificateAdmin(user) {
const data = {
to: environment.adminEmail,
cc: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5564676623273a3b153238343c397b363a38">[email protected]</a>',
subject: 'A new user has registered',
body: `
A new user has registered at XYB.
Phone Number: ${this.phone_number}
};
}