I have the following map
.dart
List<Map<String, dynamic>> symptoms = [
{'name': 'Dizziness', 'checked': false},
{'name': 'Fainting', 'checked': false}
];
My incorrect attempt in html is shown below
.html
<div class = "form-group">
<div class = "form-control"
ngControl = "symptoms">
<label for="symptom" >Symptoms</label>
<input
type = "checkbox"
*ngFor = "#symptom in symptoms"
[checked]="symptom['checked']"/>
</div>
</div>
My issues are as follows:
- The label for each checkbox should be "symptom['name'] - how do I integrate this in the *ngFor?
- How can I determine that a specific checkbox was selected?
EDIT 1
I am now seeing the checkbox and the label using the following:
<div layout = "row"
layout-align = "center"
class = "form-group"
*ngFor = "#s of symptoms">
<label>{{s['name']}} </label>
<input
type = "checkbox"
[checked] = "s['checked']"
class = "form-control"/>
</div>
However, the label seems to be on one row and the checkbox on another. I am using bootstrap.min.css and wonder if this is the main cause. The checkboxes are larger than expected too as shown below:
Cheers, and thanks Teddy