Within this particular project, I have utilized Angular 8 and TypeScript.
In the implementation, there exists an array that showcases emails either through user input or via CSV upload. Once the user inputs several emails, a button is available to send invitations to these email addresses.
To populate the emails into the array, I employ the following code snippet (where "this.emails" serves as the identifier for the array defined as emails: string[] = [];
and accessed through an ngfor loop in the HTML).
onFileInput($event: any): void {
const files = $event.target.files as File;
this.csvService
.parse(files[0], { header: false })
.pipe()
.subscribe((result: Array<any>) => {
this.emails = result;
});
}
Though this method successfully adds emails to the array, a peculiar issue arises when using the invite function. The email address within the array is identified as {"[email protected]"} instead of just [email protected].
A surprising observation is that the array actually displays [email protected]. On the other hand, manual entry correctly identifies it as [email protected].
The root of the issue seems to lie in the format of what is loaded into the array with the provided code - specifically, it is not a plain string.
Upon logging, a CSV-imported email appears as
email: Array [ "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbded6dad2d7fbcfdec8cf95dfde">[email protected]</a>" ]
, whereas a typed input email is logged as email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bedbd3dfd7d2fecadbcdca90dadb">[email protected]</a>"
(which is correct).
Hence, is there a way to adjust the function to eliminate the curly braces and quotes before entering the array?