swati kiran swati kiran - 5 months ago 36
AngularJS Question

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

Answer

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]">
Comments