ng-disabled不能与引导按钮一起使用 [英] ng-disabled not working with bootstrap buttons
问题描述
我正在将bootstrap.js和angular js一起使用,我的代码如下-
I am using bootstrap.js along with angular js, my code is following-
//few lines from controller
$scope.isWaiting = true;
$scope.promise = $http.get("voluumHandler.php?q=campaigns&filter=traffic-source&filterVal=" + traffic + "&from=" + from + "&to=" + to + "&tz=" + tz).success(function(response){
$scope.campaigns = response.rows;
console.log(response.rows);
$scope.isWaiting = false;
}).error(function(response){
alert(response);
$scope.isWaiting = false;
});
此处isWaiting
用于禁用和启用按钮.
Here isWaiting
is used for disabling and enabling the button.
<!--HTML -->
<div class="col-md-3">
<button class="btn btn-warning" ng-disabled="{{isWaiting}}">Report</button>
</div>
输出在ajax加载完成之前生成的HTML
Output HTML produced before ajax load completed
<button class="btn btn-warning" ng-disabled="true" disabled="disabled">Report</button>
在ajax加载完成后
<button class="btn btn-warning" ng-disabled="false" disabled="disabled">Report</button>
并且按钮仍然被禁用.我不确定为什么会发生这种情况,我在这里看到了几个仅回答此问题的问题.
And button is still disabled. I am not sure why is this happening, I have seen couple of questions here answered to do this only.
谢谢.
推荐答案
如果使用的是ng-disabled
,则必须使用返回真实值的表达式.表达式的一个示例是isWaiting
. {{isWaiting}}
将改为输出一个表达式.因此,请使用ng-disabled="isWaiting"
.
If you are using ng-disabled
an expression must be used that returns a truthy value. An example of an expression is isWaiting
. {{isWaiting}}
will instead output an expression. So instead use ng-disabled="isWaiting"
.
<button class="btn btn-warning" ng-disabled="isWaiting">Report</button>
这篇关于ng-disabled不能与引导按钮一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!