vendredi 25 novembre 2016

Have input checkbox toggle checked/unchecked in AngularJS 1.x

I am still new to AngularJS, I am trying to have a simple function that will toggle a checkbox on/off when clicked. So a clicked li element in the code below will either set that checkbox to on or off.

Can anyone suggest the best way to do this using AngularJS, I know jQuery would be simple but i'm trying to do this in the Angular way.

my html template

    <ul>
        <li ng-repeat="page in rule.pages" ng-click="toggleNetwork(page.id); ruleForm.$setDirty()">
            <span class="pull-left"><i class="check material-icons nomargin"></i></span>
        </li>
    </ul>   

my Controller scope logic code

$scope.toggleNetwork = function(networkId) {
   // function called when checkbox clicked

}




Aucun commentaire:

Enregistrer un commentaire