jeudi 6 octobre 2016

I have a list of checkboxes and a submit button in angularjs

I want that if any 1 job(only 1) is checked out of the list, then only the button "Cancel" must get active.

This is my html

<table >
         <tr ng-repeat="x in jobs" ng-class-odd="'odd'" ng-class-even="'even'">
            <td style="width: 247px; "><input type="checkbox" ng-model="checked"></td>
            <td style="width: 247px; "></td>
            <td style="width: 247px; "></td>
        </tr>
        </table>

<button ng-click="myFunc()" ng-disabled="countChecked()!=1">Cancel</button>

And this is my script

$scope.countChecked = function(){
        var count = 0;
        angular.forEach($scope.jobs, function(){
            if (checked) count++;
        });

        return count;
    }

How do I do it, I am new to angular? What is the problem?




Aucun commentaire:

Enregistrer un commentaire