0

So I am dynamically creating checkboxes. What I want is for each checkbox to have a value which is dynamically created. On click of the checkbox I want the values of the checkbox to append to an array.

Here is what I am working on. Am I on track?

<div *ngFor="let cuisine of cuisines"
           class="col-md-10 col-md-offset-2 cuisineinput">

        <input type="checkbox"
               id="{{cuisine.cuisine}}"
               name="{{cuisine.cuisine}}"
               (click)="cuisineappend({{cuisine.cuisine}})"
               > {{cuisine.cuisine}}

      </div> <!--cuisine div -->

now Im getting an complaint on the (click)="cuisineappend({{cuisine.cuisine}})" it doesn't like that I am passing{{cuisine.cuisine}} to the cuisineappend part. How would I pass the value?

1 Answer 1

1

It should be

<input type="checkbox"
               id="{{cuisine.cuisine}}"
               name="{{cuisine.cuisine}}"
               (click)="cuisineappend(cuisine.cuisine)"
               >

no need of {{ brackets

Working demo

Sign up to request clarification or add additional context in comments.

1 Comment

I will, I had to wait for the time to pass so I could.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.