Angular 6 link href mail
In Angular 6, you can use the href
attribute in an a
tag to link to an email address. Here are a few ways to do it:
Method 1: Using the href
attribute
<a href="mailto:[email protected]">Send an email</a>
This will create a link that, when clicked, will open the default email client on the user's device with the email address [email protected]
pre-filled.
Method 2: Using the href
attribute with a template expression
<a [href]="'mailto:' + '[email protected]'">Send an email</a>
This is similar to the first method, but uses a template expression to dynamically generate the href
attribute.
Method 3: Using the href
attribute with a pipe
<a [href]="| mailto:[email protected] |">Send an email</a>
This method uses the mailto
pipe to format the email address as a mailto link.
Method 4: Using the a
directive
<a [a]="[email protected]">Send an email</a>
This method uses the a
directive to create a link to the email address.
Note that in all cases, you need to replace [email protected]
with the actual email address you want to link to.