vendredi 27 novembre 2015

How to make a new JSON object in a JSON array with a checkbox

I have a table that shows results with a checkbox at the end of each result. There is a checkbox that puts the chosen result into an object array. How do I make it so every time I check a box, a new object will be created within the object?

HTML:

<tbody>
    <tr ng-repeat="t in student | orderBy:sortType:sortReverse | filter:query">
        <td>{{ t.idPersoon }}</td>
        <td>{{ t.voornaam }}</td> 
        <td>{{ t.tussenvoegsel }}</td>
        <td>{{ t.achternaam }}</td>
        <td>{{ t.email }}</td>
        <td>
        <div class="checkbox">
            <label>
                <input type="checkbox" data-checklist-model="user.studentid" data-checklist-value="t.idPersoon"">
            </label>
        </div>
    </td>
</tr>

Controller

$scope.user = [{
    studentid: [$scope.student] -1,
    docentid: 'nhfb',
    vakid: 'dea',
    klasid: 'oose'
}];

So right now user will be shown as

{
    [
        studentid: "123", 
        studentid: "456", 
        studentid: "789"
    ],
    tid: "nhfb", 
    vakid: "dea", 
    klasid: "oose"
}

but I want the structure to be

[{
    studentid: "123", 
    docentid: "nhfb", 
    vakid: "dea", 
    klasid: "oose"
} {
    studentid: "456", 
    docentid: "nhfb", 
    vakid: "dea", 
    klasid: "oose"
}]




Aucun commentaire:

Enregistrer un commentaire