現在,我正在使用複選框來禁用/不可禁用其他按鈕的單擊。 我的代碼是在這裏:
<button class="dateicon" ng-disabled='ExpReport.Beld' ng-click="openstart($event)">button1</button>
<button ng-disabled='ExpReport.Beld' class="dateicon" ng-click="openend($event)">button2</button>
<input id='beld' ng-model='ExpReport.Beld' class='checkboxinline' type='checkbox'/>
$scope.ExpReport.Beld = false;
$scope.$watch('ExpReport.Beld',function(){
if($scope.ExpReport.Beld=true){
$scope.ExpReport.startdate = '';
$scope.ExpReport.enddate = '';
}
})
好像複選框始終設置爲false,當我提出一個斷點,它會設置爲true,然後馬上轉回來爲false。任何想法?
把一個Plunker或JSBin,但你的問題是比較的標誌,'''scope.ExpReport.Beld === true''',而不是''scopepace.ExpReport.Beld = true''' – TheUnnamed
'$ scope.ExpReport.Beld === true'可能是多餘的;只需使用'$ scope.ExpReport.Beld'。 –