javascript - angularJs ng-禁用不工作

标签 javascript jquery html angularjs

{
    $scope.editable = true;
    $scope.NewEmployee = function () {
        $scope.editable = false;
    };

    $scope.EditEmployee = function () {
        $scope.editable = false;
        $scope.Employee.edit = true;
    };

    $scope.Cancel = function () {
        $scope.editable = true;
    };
}

<button ng-click="NewEmployee()"></button>
<button ng-click="EditEmployee()" ></button>
<button ng-click="Save()" ng-disabled="editable"></button>
<button ng-class="Cancel()" ng-disabled="editable"></button>

当只有 NewEmployee() 时它起作用

但我添加了 EditEmployee() Save() Cancel() 其中之一它不起作用

最佳答案

您的代码中有一个 TYPO 错误

<button ng-class="Cancel()" ng-disabled="editable"></button>

ng-class="Cancel()"这应该像 ng-click="Cancel()"

关于javascript - angularJs ng-禁用不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37251507/

相关文章:

javascript - 如何在 JavaScript 中创建提前输入功能

JQuery CSS $ (':animated' ).动画在屏幕上完成后的长度延迟

html - 溢出 x 轴不工作

javascript - 如何使用 D3JS 创建带有网格线的 SVG

javascript - 如何在 Angular2+ 中使用 ngStyle 将转换翻译属性应用于元素

javascript - 窗口调整大小不起作用

javascript - vis.js 时间轴,不要堆叠没有时间重叠的项目

jQuery - 单击后显示一个 div 并关闭另一个

javascript - 单击其他元素时将类应用于元素

javascript - 单击时如何扩展 3D 矩形以显示更多矩形?