lundi 7 novembre 2016

Change this number into a checkbox inside a table on angularjs

I have this html code which uses angularjs to display contents in a table.

<div ng-controller="CheckCtrl">
    <table class="table table-hover data-table sort display">
        <thead>
        <tr>
            <th class="Serial_">
                Serial
            </th>
            <th class="Name_">
                Name
            </th>
            <th class="ID_">
                ID
            </th>
            <th class="On_off_">
                On/off
            </th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="item in check_items">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tbody>
    </table>
</div> 

The webpage looks like this;

enter image description here

Here is the controller code.

.controller('CheckCtrl', ['$scope', '$http', 'configuration', 
    function ($scope, $http, $configuration) {
        var url_api = $configuration.host + "cloe/webroot/cloe-cloud/app/API.json";
        $http.get(url_api).success(function(data)
        {
            $scope.check_items = data;
        });

I would like to change the On/Off columns number values into a checkbox. If the number value is 0, the checkbox is unchecked. If the number value is 1, the checkbox is checked.

I am using angularjs v1 and twitter bootstrap.




Aucun commentaire:

Enregistrer un commentaire