app.directive('loading', ['$http' ,function ($http)  
{  
    return {  
        restrict: 'A',  
        template: '<div class="loading-spiner"><img src="img/loading.gif" /> </div>',  
        link: function (scope, elm, attrs)  
        {  
            scope.isLoading = function () {  
                return $http.pendingRequests.length > 0;  
            };  
 
            scope.$watch(scope.isLoading, function (v)  
            {  
                if(v){  
                    elm.style.display = 'block';  
                }else{  
                    elm.style.display = 'none'; 
                }  
            });  
        }  
    };  
}]);

@@ -226,28 +226,16 @@
 , attrs)
-  %0D%0A        
 %7B  %0D%0A   
@@ -413,16 +413,17 @@
 tion (v)
+%7B
   %0D%0A    
@@ -430,19 +430,37 @@
         
-%7B
   
+  console.log(elm);
 %0D%0A      
@@ -508,30 +508,13 @@
 lm.s
-tyle.display = 'block'
+how()
 ;  %0D
@@ -568,31 +568,16 @@
 elm.
-style.display = 'none';
+hide(); 
  %0D%0A 

Update loading.js