我正在使用 xeditable Angular Directive(指令)。你能告诉我如何使用 2 个取消按钮吗?因为我需要在上面实现 2 个功能。我的意思是 cancel + my work 1
和 cancel + my work 2
。提前致谢。
HTML
<form editable-form name="tableform" onaftersave="saveTable()" oncancel="cancel()">
//UI code here
<button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">Cancel</button>
</form>
JS
// cancel all changes
$scope.cancel = function() {
};
最佳答案
您可以在表单中设置 2 个取消按钮,并将表单作为属性传递。然后在相应的取消函数中,您可以调用 form.$cancel 然后执行您的逻辑。 form.$cancel
执行与调用 ng-click="tableform.$cancel()"
相同的工作。
使用它:Plunker
//html
<button type="button" ng-disabled="tableform.$waiting" ng-click="cancel1(tableform)" class="btn btn-default">cancel 1</button>
<button type="button" ng-disabled="tableform.$waiting" ng-click="cancel2(tableform)" class="btn btn-default">cancel 2</button>
//controller
$scope.cancel1 = function(tableForm) {
// Call tableForm cancel to reset
tableForm.$cancel();
//Logic1
};
$scope.cancel2 = function(tableForm) {
// Call tableForm cancel to reset
tableForm.$cancel();
//Logic2
};
关于javascript - 2 Xeditable Angular Directive(指令)上的取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31383253/