0

enter image description herehi 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>
2
  • what is the response from db of contacts.Active Commented Mar 10, 2017 at 12:07
  • its true or false value @nivas Commented Mar 10, 2017 at 12:16

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

7 Comments

it's hard coded means works fine i get value from DB but it's won't checked kindly verify@digit
It's not the checkbox issue, it's data from db issue. Please check that the value from db is a boolean and not a string.
hi @digit i edit mu post now check it's contain any mistake
contacts.Number is a string value. Convert it to boolean. I'll update my answer
it's work's and correctly. i need when page load directly shows checkbox checked/unchecked .not show true or false
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.