I am dynamically creating a dropdown list of items using ngFor, looping through a string array (obtained from an SQL query), saved within a service.
<li *ngFor="let vehicleClasses of getVehicleClassList(); let i = index" (click)="toggleCheckBox(i)">
<a>
<input type="checkbox" id="vehCB_{{i}}"/>{{vehicleClasses}}
</a>
</li>
The dropdown menu has a checkbox and then the name of the selection ({{VehicleClasses}}.
How do I store which checkboxes the user has checked (and preferably from within the service rather than the component)?
Ideally, I want to have a boolean array which store the checkbox value. If it is possible, can I then bind the checkbox to a value so if, for example, a function were to change all the checkbox booleans, the checkboxes would update?
I've seen ngModel used in other similar scenarios - but I have not been able to successfully get it working.