我有這種形式:ngDisabled和ngClick不能一起工作
<div class="form-group">
<label for="GrpName"> Mail:</label>
<input ng-model="customerToUpdate.mail" type="text" class="form-control" id="name">
<button type="button" class="btn btn-default" ng-click="loadCustomer()">
Load
</button>
</div>
<div class="form-group">
<label for="GrpName"> Username:</label>
<input ng-disabled="{{isDisabled}}" ng-model="customerToUpdate.username" type="text" class="form-control" id="name">
</div>
控制器:
$scope.isDisabled = true;
$scope.loadCustomer = function() {
Customer.getByEmail($scope.customerToUpdate.mail)
.success(function(customer, status, headers, config) {
if(!isEmptyObject(customer)){
$scope.isDisabled = false;
}else
$scope.isDisabled = true;
});
};
使用Chrome,我可以檢查並看到ng-disabled
改爲true
和false
但沒有UI更新。我也試過readonly
代替,但相同的結果..
我失去了一些東西?
應NG-禁用= 「isDisabled」 –
解決了,可你讓一個答案?我不明白區別..爲什麼ng-disabled在檢查模式下更改爲true和false,但在UI中沒有更改? –
總結:ng-disabled使用'=',所以你必須傳遞變量(不是值),否則指令失敗並且什麼也不做,所以它仍然是ng-disabled =「...」(不是disabled =「...」 ) –