samedi 26 septembre 2015

Angular checkbox input ng-click never called

In my Angular app, I have a form with checkbox inputs:

<div ng-repeat="partner in type.partners">
    <label class="checkbox-inline">
        <input type="checkbox" value="partner"
        ng-checked="report.participatingPartners[$parent.$index].indexOf(partner) !== -1" 
        ng-click="vm.toggleSelection($parent.$index, $index);">
        <p><span></span>{{partner.name}}<p>
    </label>
</div>

And in my controller, just to test this setup:

var vm = this;
vm.toggleSelection = toggleSelection;

...

function toggleSelection(typeId, partnerId) {
    console.log("toggleSelection called");
    console.log(typeId, partnerId);
}

This function never gets called when I click the checkbox or its label. Why is that?

I know it's not the controllerAs syntax because other functions are working fine.




Aucun commentaire:

Enregistrer un commentaire