I´m trying to create a table that has multiple checkboxes with different states (some are true, other false).
In this table i have 'Save' button to featch all elements with his state.
The code is like:
<form #form="ngForm" (ngSubmit)="save(form)">
<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger"
class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>name-placeholder</th>
<th>action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let card of cardsDashboard;let i=index">
<td></td>
<td>
<div class="form-check">
<label>
<input type="checkbox" name="checkDashboard" [(ngModel)]="card[i]"
(ngModelChange)="card[i].activate==true?'true':'false'" [checked]="card.activate">
<span class="label-text"></span>
</label>
</div>
</tr>
</tbody>
</table>
<div class="btn-toolbar pull-right ">
<div class="btn-group">
<button class="btn btn-primary">save</button>
</div>
</div>
</form>
The first problem: 'Save' button doesn´t update the state of elements.
Second problem: The checkboxes doesn´t show default state. Checkbox is null.
So the question is: How can i do a ngfor with checkboxes and show the state and update it?
Aucun commentaire:
Enregistrer un commentaire