Concatenate strings and variable values in angular html template

Just use the simple quotes ' and + sign inside the double quotes of the html attribute value. See the value of the href attribute below:

<div class="float-right mt-1">
  <a
    *ngIf="snippet.public"
    type="button" class="btn btn-light btn-sm float-right"
    href="mailto:?subject=Code snippet: &body=https://www.codever.land/snippets/"
    title="Share link to snippet via Email">
    <i class="far fa-envelope"></i> Email
  </a>
</div>

Reference - https://github.com/codeverland/codever


Shared with from Codever.land. Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Subscribe to our newsletter for more code resources and news

Adrian Matei

Adrian Matei
Life force expressing itself as a coding capable human being