SHARE
TWEET
Untitled
a guest
Jul 21st, 2014
200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- triggered with
- <element loading data-action="callThisFunction($event)">
- angular.module('loadingOverlay').directive('loading', ['$rootScope', '$timeout', '$q', function($rootScope, $timeout, $q) {
- return {
- restrict: 'A',
- priority: 100,
- terminal: false,
- controller: function() {
- },
- link: function (scope, element, attrs) {
- var clickAction = attrs.action;
- scope.$tapHandler = function(event) {
- element.unbind('click');
- event.stopPropagation();
- event.stopImmediatePropagation();
- scope.$apply(function() {
- $rootScope.AILoading = true;
- $timeout(function() {
- scope.$eval(clickAction);
- }, 0);
- });
- var unbindWatcher = $rootScope.$watch('AILoading', function(newVal) {
- if(newVal == false) {
- element.bind('click', scope.$tapHandler);
- unbindWatcher();
- }
- });
- };
- element.bind('click', scope.$tapHandler);
- }
- }
- }]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

