Set and get attributes from HTML templates

Last Updated on: (senast uppdaterad på:)

Set an attribute by using square brackets, name of attribute, and its value:

<ng-container *ngIf="arrIngredients">
    <div id="ingsBox">  
        <div class="ing"
        *ngFor="let ing of arrIngredients;">
            {{}} <br>
            <!-- {{ing.description}} -->

Get it in the components via the getAttribute method, i.e.:

  toggleClick(event) { //example function
    alert("name")); //getting it here.

Lämna ett svar