Javascript ng禁用不使用引导按钮
我正在使用bootstrap.js和angular js,我的代码如下-Javascript ng禁用不使用引导按钮,javascript,ajax,angularjs,twitter-bootstrap,Javascript,Ajax,Angularjs,Twitter Bootstrap,我正在使用bootstrap.js和angular js,我的代码如下- //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
//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
用于禁用和启用按钮
<!--HTML -->
<div class="col-md-3">
<button class="btn btn-warning" ng-disabled="{{isWaiting}}">Report</button>
</div>
报告
输出ajax加载完成前生成的HTML
<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>
报告
按钮仍然处于禁用状态。我不知道为什么会发生这种情况,我在这里看到了几个问题的答案,只是为了这样做
提前感谢。如果您使用的是
ng disabled
则必须使用返回真实值的表达式。表达式的一个示例是isWaiting
<代码>{{isWaiting}将改为输出一个表达式。因此,请改用ng disabled=“isWaiting”
报告
您需要给一个表达式给
ng disabled
,而不是给一个字符串(“true”/“false”),该字符串总是truthy,按钮总是被禁用
isWaiting
-->表达式
{{isWaiting}
-->表达式的值
就你而言:
ng-disabled="isWaiting"
@但是为什么呢?@PSL这个问题是问我的还是问你的我是说在回答中提供一个小的解释会很好,你觉得呢?因此,未来的游客不会想知道为什么:)
ng-disabled="isWaiting"