app.directive('loading', function() { return { restrict: 'E', transclude: true, template: '', link: function(scope, element, attr) { scope.$watch('loading', function(val) { if (val) { document.getElementById("allDiv").style.display = "block"; } else { document.getElementById("allDiv").style.display = 'none'; } }); } } });