在配置文件中加入一下代码,即可解决全局的ngClick重复点击。此方法是重写ngClick事件,可以保护多次点击,本来想扩展成指令,不过发现angular规定ngClick就是单击事件,此处以作归纳 事件指令
app.config(['$provide', function ($provide) { $provide.decorator('ngClickDirective',['$delegate','$timeout', function ($delegate,$timeout) { var original = $delegate[0].compile; var delay = 500; $delegate[0].compile = function (element, attrs, transclude) { var disabled = false; function onClick(evt) { if (disabled) { evt.preventDefault(); evt.stopImmediatePropagation(); } else { disabled = true; $timeout(function () { disabled = false; }, delay, false); } } // scope.$on('$destroy', function () { iElement.off('click', onClick); }); element.on('click', onClick); return original(element, attrs, transclude); }; return $delegate; }]); }]);