Friday, 19 August 2016

Single checkable checkbox-angularjs

No comments
Html

<ion-item class="item-checkbox">
    <label class="checkbox">
   <input type="checkbox" ng-model="hrq.checked" ng-value="hrq.AnswerID" ng-  click="selectedAnswer($index,HrqQuestions,hrq.AnswerID,hrq.Answer)" >
   </label>
{{ hrq.Answer}}

</ion-item>


Js


$scope.selectedAnswer = function (position, questions, answerId, answer) {            
        angular.forEach(questions, function (subscription, index) {
            if (position != index)
                subscription.checked = false;
            $scope.selected = answerId;
        }
        );

    }