Reputation: 2550
I am working on AngularJs app where I need to show Name of customer but it should mail to link with email to his email address.
Eg : If name is Bob
and email is [email protected]
, then on click of Bob it should show mail to [email protected]
my html as as below
<div class="form-group mg-t20" ng-hide="!groupObj.accountExecutiveName">
<label class="wd50p control-label left fw-norm">Account Executive:</label>
<div class="wd48p blue-txt">
{{groupObj.accountExecutiveName}}
</div>
</div>
I do have email property . Its groupObj.accountExecutiveEmail
. How do i do this in html ?
Upvotes: 0
Views: 8348
Reputation: 5732
Angular2+:
<a [href]="'mailto:' + groupObj.accountExecutiveEmail" target="_blank">Send mail</a>
Upvotes: 1
Reputation: 5703
The following code should work in your case:
<a ng-href="mailto:{{ groupObj.accountExecutiveEmail }}" target="_blank">
{{ groupObj.accountExecutiveName }}
</a>
So your final HTML will look like this:
<div class="form-group mg-t20" ng-hide="!groupObj.accountExecutiveName">
<label class="wd50p control-label left fw-norm">Account Executive:</label>
<div class="wd48p blue-txt">
<a ng-href="mailto:{{ groupObj.accountExecutiveEmail }}" target="_blank">
{{ groupObj.accountExecutiveName }}
</a>
</div>
</div>
Cheers!
Upvotes: 3
Reputation: 1127
mailto:
in an <a>
tag is the way to go.
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Email_links
<a href="mailto:[email protected]">Bob</a>
Upvotes: 2
Reputation: 1891
You can add something like this to your template:
<a ng-href="mailto:{{groupObj.accountExecutiveEmail}}" target="_blank">
{{groupObj.accountExecutiveName}} --> here will be the item's name
</a>
Upvotes: 2