0
我已经尝试了其他答案的几个解决方案,但到目前为止没有按需工作,基本上我需要禁用按钮(锚点)如果窗体无效,禁用不是问题,避免对函数的调用。禁用点击锚如果窗体无效
对于我想是这样的:
<a class="btn icon-btn btn-success" ng-disabled="myForm.$invalid" novalidate ng-submit="myForm.$valid && submit.addOrEditItem()">
<span class="glyphicon btn-glyphicon glyphicon-save img-circle text-success"></span>Save</a>
而且我控制器上:
$scope.isCreating = true;
$scope.submit = {
addOrEdit: function() {
if($scope.isCreating){
$scope.items.push({type: $scope.newItem.name, description: $scope.newItem.descriptions, isDone:false, editable:false});
}else{
$scope.eItem.type = $scope.newItem.name;
$scope.eItem.description = $scope.newItem.descriptions;
}
$scope.isCreating = true;
$scope.newItem = {};
}
}
对此有任何的替代品?
我发誓,我试过,之前并没有奏效。 –
@CodeGrasshopper,也许是因为你的函数调用为submit.addOrEditItem,当正确的函数名是submit.addOrEdit时。 – Skaparate
你当然是对的。谢谢! –