Checkbox无法加载文件,但是在页面刷新后工作
我的template
:
<div class="checkbox">
<label>
<input type="checkbox" id="farmCat" class="farmCatCrop" ng-click="valueChangedTwo()"> Crop </label>
<label>
<input type="checkbox" id="farmLive" class="farmCatLiveStock" ng-click="valueChangedTwo()"> Live Stock </label>
</div>
现金
家畜
我的method
:
$scope.valueChangedTwo = function() {
if ($('.farmCatCrop').is(":checked"))
$("#cash").show();
else
$("#cash").hide();
if ($('.farmCatLiveStock').is(":checked"))
$("#liveField").show();
else
$("#liveField").hide();
};
答案 0 :(得分:0)
<div class="checkbox">
<label>
<input type="checkbox" id="farmCat" class="farmCatCrop" ng-model="cat.crop">Crop </label>
<label>
<input type="checkbox" id="farmLive" class="farmCatLiveStock" ng-model="cat.livestock">Live Stock </label>
</div>
然后......
<div id="cash" ng-show="cat.crop">Cash</div>
<div id="liveField" ng-show="cat.livestock">Live Stock</div>
你不会需要jQuery,因为angularjs可以做得更好。