单击AngularJS 1.3.15中的另一个按钮,禁用“提交”按钮

时间:2017-01-21 18:00:31

标签: html angularjs button angularjs-ng-disabled

我有2个按钮 - 删除和提交。最初禁用“提交”按钮。每当用户点击“禁用”按钮时,我都会尝试启用“提交”按钮。我在这个项目中使用AngularJS 1.3.15。

main.html中

<body>
<button ng-disabled="isItemDeleted" ng-init="isItemDeleted=true" 
class="btn btn-lg btn-primary create-txn-button" ng-click="submit()">Submit Transaction</button>  

deleteController.js

angular.module('myApp').controller('myCtrl',
function{};     
$scope.deleteItem = function(item) 
{
    $scope.isItemDeleted = false;
    var modalScope = $scope.$new(true);
    modalScope.message = 'Why would you like to delete this item?';
    modalScope.item = item;
    modalScope.transaction = $scope.transaction;
};

但是,即使将$scope.isItemDeleted设置为false,也不会启用提交按钮。我相信问题是连接到控制器。我必须将我的div标签连接到控制器。但如果我这样做,整个页面就会改变。任何线索?

更新:删除按钮调用deleteItem()函数。

DeleteButtonTabView.html

<div ng-controller="myCtrl">
<button ng-click="deleteItem(item)" class="btn btn-info btn-sm">Delete</button>
</div>

请找到JSFiddle的链接:https://jsfiddle.net/L1bnv9fr/

0 个答案:

没有答案