mercredi 24 février 2016

angularjs + get multiple checkbox value and attribute values

I am trying to get the multiple checkbox value and attribute values.

Each checkbox have multiple attribute values(data-id, data-ot,data-si).

How to get the checked checkbox with 3 attribute values.

<table>
    <thead class="search">
        <tr>
            <th>
            <input type="checkbox" class="selectall " ng-model="selectall" ng-click="select(data)">
            </th>
        </tr>
    </thead>
    <tbody>
        <tr >
            <td>
            <input data-id="287" data-ot="31" data-si="541" type="checkbox" - ng-model="rowselect">
            </td>
        </tr>
        <tr  >
            <td>
            <input data-id="295" data-ot="331" data-si="31" type="checkbox"  ng-model="rowselect">
            </td>

        </tr>
        <tr  >
            <td>
            <input data-id="297" data-ot="321" data-si="31" type="checkbox"  ng-model="rowselect">
            </td>
        </tr>
        <tr  >
            <td>
            <input data-id="296" data-ot="451" data-si="671" type="checkbox"  ng-model="rowselect">
            </td>
        </tr>
        <tr  >
            <td>
            <input data-id="293" data-ot="91" data-si="651" type="checkbox"  ng-model="rowselect">
            </td>
        </tr>
        <tr  >
            <td>
            <input data-id="294" data-ot="13" data-si="14" type="checkbox"  ng-model="rowselect">
            </td>
        </tr>
    </tbody>
</table>

<input type="button" name="Submit" value="Submit" ng-click="ShowSelected()" />

Expected output:

For example 2 checkbox selected selected means:

[{"id":"xx","ot":"xx","si"},{"id":"xx","ot":"xx","si"},]

Code:

app.controller('MyCtrl', function($scope) {
    $scope.ShowSelected = function() {
     ///
    };
});




Aucun commentaire:

Enregistrer un commentaire