swati kiran
swati kiran

Reputation: 705

ng-checked not working in angularjs

while in edit mode checkbox is not getting checked!! in html i have this

<input type="checkbox" ng-model="overallfeedback" ng-change="collectFeedback(overallfeedbackElg, $index)" ng-checked="{{collectlistbla[$index]}}">

in ng-change i tried to push model vales in a array...

$scope.collectFeedback = function(oveallfeedbackElg, index){

    if($scope.collectlistbla.hasOwnProperty(index))
      $scope.collectlistbla.splice(index, 1, oveallfeedbackElg);
    else
      $scope.collectlistbla.push(oveallfeedbackElg);

    console.log($scope.collectlistbla);

  };

in edit page while getting responce .....

         console.log(response.overallfeedback);//true,true,true,true,true
        $scope.collectlistData = response.overallfeedback;
        $scope.collectlistbla= $scope.collectlistData.split(',');
        console.log($scope.collectlistbla);//["true", "true", "true", "true", "true"]

i must be doing some mistake.. do help... thanks in advance

Upvotes: 1

Views: 186

Answers (1)

Marcus H&#246;glund
Marcus H&#246;glund

Reputation: 16801

Inside the ng- tags you don't need to use the {{}} to bind.

Try this:

<input type="checkbox" ng-model="overallfeedback" ng-change="collectFeedback(overallfeedbackElg, $index)" ng-checked="collectlistbla[$index]">

Upvotes: 1

Related Questions