I have list of object to show for checkboxes
public weeks = [
{ value: 'All', display: 'All',isChecked: false },
{ value: 'Mon', display: 'Mon',isChecked: false },
{ value: 'Tue', display: 'Tue',isChecked: false },
{ value: 'Wed', display: 'Wed',isChecked: false },
{ value: 'Thu', display: 'Thu',isChecked: false },
{ value: 'Fri', display: 'Fri',isChecked: false }
];
app.component.html
<span *ngFor="let month of months">
<label>
<input type="checkbox" name="months" [(ngModel)]="month.isChecked" class="months" >
</label>
</span>
Issue is that it now bind selected checkboxes .
app.component.ts
this.weeks.forEach((month) => {
var i = this.selected_weeks.indexOf(month.week);
if(i != -1) {
week.isChecked = true;
console.log(week.isChecked);
}
});
in component it mark that object true but in view it not selected
Aucun commentaire:
Enregistrer un commentaire