hi all i work with angularjs ng-repeat .i want to bind checkbox based on db value true or false.but checkbox will not check/uncheck whether db value is true?
serverjs// app.get('/contactdetail', function (req, res) {
console.log('I received a GET request');
db.contactdetail.find (function (err,docs) {
console.log(docs);
res.json(docs);
});});
controller var refresh = function () {
$http.get('/contactdetail').success(function (response) {
console.log('I received a GET request');
$scope.contactdetail = response;
});
};refresh();
<tr ng-repeat="contacts in contactdetail><span editable-checkbox="contacts.Number" e-name="Number" e-form="rowform" onaftersave="Dhkclick(contacts._id,contacts.Number)">{{ contacts.Number|| 'empty' }}
</span></tr>
Remove e-name and e-form attirbutes in the editable-checkbox and bind the checkbox ngmodel with data from db and it will worked. For eg:
<span editable-checkbox="contacts.Number" onaftersave="Dhkclick(contacts._id,contacts.Number)">
{{ contacts.Number|| 'empty' }}
Update
Please make sure contacts.Number is boolean, if it is a string convert it to the boolean first
angular.forEach($scope.contactdetail, function (v) {
if (v.Number === 'true') {
v.Number = true;
} else if (v.Number === 'false') {
v.Number = false;
}
});
Update JsFiddle Link : http://jsfiddle.net/ts3LxjLc/9/