双向数据绑定不适用于Data-ng-Disabled



我如何才能让btnDisabled在即时函数范围中更改data-ng-disabled,但在我的ajax Success内部范围范围内,没有什么表现。我如何获取按钮 disable

JS

.controller('CouponCtrl', function($http, $scope) {
  $scope.btnDisabled = false;
  // $scope.btnDisabled = true; // this works fine too
  $http.jsonp("someurl?_jsonp=JSON_CALLBACK").success(function(){
    $scope.btnDisabled = true; // does not work
    console.log("I see this so why doesn't my button disable?");
    // $scope.$digest(); // tried this too but I'm told digest is already running
  }
}

html

<button data-ng-disabled="{{ btnDisabled }}" class="button button-block green">redeem coupon</button>

注意

我注意到,当我通过 ajax Success更新变量范围范围时,我的双向数据绑定都没有。有没有办法克服?

ngDisabled期望表达式,而不是字符串(插值总是输出字符串值):

<button data-ng-disabled="btnDisabled" 
        class="button button-block green">redeem coupon</button>

工作plunker

更改

data-ng-disabled 

to

ng-disabled