我的HTML ...................................... .....................................角度js ng-dissabled不起作用
<div id="ButtonController" ng-app="buttons" ng-controller="ButtonController as controller">
@*<span ng-disabled="controller.access.canClose">@Html.Kendo().Button().Name("tabDelete").Content("Close").Icon("cancel")</span>
<span ng-disabled="controller.access.canEdit">@Html.Kendo().Button().Name("Edit").Content("Edit")</span>*@
<button ng-disabled="controller.access.canClose" class="k-button k-button-icontext" title="Close Tab" type="button" id="tabDelete" >Close</button>
<button ng-disabled="controller.access.canEdit" class="k-button k-button-icontext" title="Edit" type="button" id="Edit" >Edit</button>
<button id="save" class="k-button k-button-icontext" >Save</button>
</div>
我的js
(function() {
var app = angular.module('buttons', []);
app.controller('ButtonController', function ($scope, $http) {
$scope.myfunctions = function (obj) {
if (obj != "Stop") {
$http.get("/home/setButtonRights?tr_code=" + obj)
.success(function (response) {
buttonVisibility.canClose = response.canClose;
buttonVisibility.canEdit = response.canEdit;
})
.error(function() { alert("Done") });
} else {
buttonVisibility.canClose = true;
buttonVisibility.canEdit = true;
}
}
this.access = buttonVisibility;
});
}
var buttonVisibility = {
canEdit: true,
canClose:true
}
})();
當我通過「停止」這個控制器按鈕仍然活躍。我想在stop obj到來時禁用這些按鈕。
你所說的'的意思,當我通過「停止」這一controller' –
您是否獲得在控制檯中的任何錯誤? – Tushar
在ng-disabled或(更好)使用ng-enabled中反轉表達式。 – ChristophT