SHARE
TWEET
Untitled
a guest
Jul 21st, 2014
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- triggered with:
- <element loading data-action="callThisFunction($event)">
- watcher:
- <div ng-show="AILoading" class="loading-spinner">
- <div>
- <i class="fa fa-spin fa-spinner"></i>
- </div>
- </div>
- 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.isClicked = false;
- scope.$tapHandler = function(event) {
- console.log('click, isClicked: ' + scope.isClicked);
- if(scope.isClicked == true) {
- return;
- }
- //element.unbind('click');
- scope.isClicked = true;
- event.stopPropagation();
- event.stopImmediatePropagation();
- scope.$apply(function() {
- $rootScope.AILoading = true;
- $timeout(function() {
- scope.$eval(clickAction);
- }, 0);
- });
- //scope.$eval(clickAction);
- var unbindWatcher = $rootScope.$watch('AILoading', function(newVal) {
- if(newVal == false) {
- //element.bind('click', scope.$tapHandler);
- scope.isClicked = false;
- 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.

