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>{{item.SERIAL}}</td>
<td>{{item.NAME}}</td>
<td>{{item.ID}}</td>
<td>{{item.ON_OFF}}</td>
</tbody>
</table>
</div>
The webpage looks like this;
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 character into a checkbox. If the number character is ‘0’, the checkbox is unchecked. If the number character is ‘1’, the checkbox is checked.
I am using angularjs v1 and twitter bootstrap.
EDIT: Sorry, I realized that my checkbox value is a character, not a number. They are ‘0’, ‘1’ and not 0, 1.
3
Answers
Think that should do it.
ng-true-value
the value that will set the input checkedng-false-value="0"
the value that will set the input uncheckedAngular Documentation
https://docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D
Hope this will help.