The most basic example to do this is append the selectedValue
from the dropdown at the end of the href
.
<p>
<a [href]="'mailto:cybertruck@wrapmate.com?subject=Cybertruck%20Request&body=' + selectedValue">Send an email</a>
</p>
Here's the full HTML of the page with some dummy data coming from the component. The value gets updated in the ngModel
, so it's usable everywhere on the page.
<select [(ngModel)]="selectedValue">
<option *ngFor="let item of items" [ngValue]="item.name">{{item.name}}</option>
</select>
<p>You selected: {{ selectedValue }}</p>
<p *ngIf="selectedValue">
<a [href]="'mailto:cybertruck@wrapmate.com?subject=Cybertruck%20Request&body=' + selectedValue">Send an email</a>
</p>
To see this in action, follow this StackBlitz.