I have the following HTML
<div ng-repeat="campaign in campaigns" >
<label for="campaignPaused">Paused</label>
<input type="checkbox" ng-model="campaign.paused"class="check_box" />
<p>campaign.paused == {{campaign.paused}}</p>
Initially, the debug text shows that $scope.campaign.paused is false, which is correct, and the checkbox is correctly unchecked.
If I click the checkbox, the debug text changes to true, but the checkbox remains visually unchecked.
Subsequent clicks to the checkbox have no effect.
Now for the weird part: if I remove that ng-click="CampaignClicked($event, campaign.campaign_id)" then the checkbox works correctly!
Aha!, I thought - the click on the checkbox is peculating up to its parent. And, it was, although that CampaignClicked() simply swallowed the event and returned, sicne it wasn't ewxpecting ot be clicked.
To make things clearer, I changed the checkbox to
<input type="checkbox" ng-model="campaign.paused" ng-click="SwallowClick($event)" class="check_box" />
where I have declared
$scope.SwallowClick = function($event)
{
if ($event.cancelable)
$event.preventDefault();
$event.stopPropagation();
return false; // don't handle event further
}
But, the checkbox is still behaving as before.
Can anyone see why? (Note that if I move the checkbox before the DIV, it works correctly)