【发布时间】:2015-12-16 16:13:12
【问题描述】:
这是我的代码:
$scope.toggleBandPics = function(bandid){
for (var picid in $scope.bands[bandid]['pics']) {
$scope.bands[bandid]['pics'][picid]['show'] = ($scope.bands[bandid]['pics'][picid]['show'] == 'true'? 'false': 'true');
}
}
<span ng-repeat="band in bands">
<div class="bandsfilter">
<span ng-show="bButtons">
<input class="checkbox"
name="{{band.urlbandname}}"
type="checkbox"
id="{{band.urlbandname}}"
ng-model="band.checked"
ng-checked="{{band.checked}}==true"
ng-true-value="{{band.checked}}==true"
ng-false-value="{{band.checked}}==false"
ng-change="toggleBandPics({{band.bandid}})"
/>
{{band.bandname}} ({{band.noOfPicsPerBand}})
<span id="counter{{band.bandid}}" class="hidden">
{{band.noOfPicsPerBand}}
</span>
<span>
</div>
</span>
<span ng-repeat="band in bands">
<span ng-repeat="picture in band.pics">
<div class='picture' ng-show="picture.show=='true'" ng-cloack>
<a class="shadowbox{{picture.bandid}} photo" rel="shadowbox[{{humanconcertdate}}]" title="{{picture.bandname}}, {{humanconcertdate}}, {{venuename}}" href="/concert2/{{band.concertid}}/{{band.bandid}}/{{picture.filename}}">
<img src="/concert2/{{picture.concertid}}/{{picture.bandid}}/{{picture.filename}}" alt="{{picture.bandname}}, {{humanconcertdate}}, {{venuename}}" />
</a>
</div>
</span>
</span>
现在,当我运行这个 ng-change 时,除了第一次未选中选中的复选框外,它都会被触发。当它再次被检查时(所以当它被第二次点击时)它会触发。
【问题讨论】:
标签: angularjs checkbox angularjs-ng-change