AngularJs:ng-disabled在event.target.setAttribute中不起作用

时间:2017-10-11 12:25:02

标签: angularjs angularjs-directive

JS

$scope.change = function(event){ 
       event.target.innerHTML = "connecting <i class='fa fa-refresh fa-spin' 
                  aria-hidden='true'></i>";
       event.target.setAttribute("ng-disabled",true); 
    }

HTML

<button class="btn-invite"  ng-click="change($event)">Connect <i class="fa fa-plug" aria-hidden="true"></i> </button>

没有禁用按钮?

2 个答案:

答案 0 :(得分:1)

在控制器内更改禁用禁用

$scope.change = function(event){ 
       event.target.innerHTML = "connecting <i class='fa fa-refresh fa-spin' 
                  aria-hidden='true'></i>";
       event.target.setAttribute("disabled",true); 
    }

答案 1 :(得分:0)

从角度ng-点击你不能直接调用javascript函数你必须在控制器中定义并从angular js html调用 像是

控制器代码:

$scope.change = function (event) {
    event.target.innerHTML = "connecting <i class='fa fa-refresh fa-spin' 
    aria - hidden = 'true' > < /i>";
    event.target.setAttribute("ng-disabled", true);
}

工作演示http://plnkr.co/edit/5V6n6K0BhH1tcQ2LOTpl