mardi 9 février 2021

Add multiple checkboxes based on input length in Angular

Currently, I have a single checkbox in my Angular application which I plot using the HTML code:

<input type="checkbox" id="box1" value="Apple">
<label for="box1"> Apple</label>

However, I now need to tweak the functionality such that the number of checkboxes is dependant on the array input. Also, the contents of the arrays should be the labels for the checkboxes.

For ex:

If my array is arr = ['Apple', 'Mango','Banana'], I should get 3 checkboxes (as the length of arr is 3) like this: enter image description here

How can I do this?




Aucun commentaire:

Enregistrer un commentaire