Created
June 13, 2013 16:08
-
-
Save mbalex99/5774963 to your computer and use it in GitHub Desktop.
Loadable Directive for Angularjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
Application.Directives.directive("loadable", function() { | |
return { | |
restrict: "A", | |
templateUrl: "/partials/loading/loadable.html", | |
transclude: true, | |
scope: { | |
loadable: "@" | |
}, | |
link: function(scope, element, attrs) { | |
scope.$watch('loadable', function(newValue, oldValue) { | |
if (newValue === "true") { | |
$(element).find('.loadable-content').fadeTo(0.1, 0); | |
} | |
if (newValue === "false") { | |
$(element).find('.loadable-content').fadeTo(100, 1); | |
} | |
}); | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<div class="ajax-loader" style="text-align: center" ng-show="loadable === 'true'"> | |
<img src="/Assets/img/bar-loading.gif" /><br /> | |
</div> | |
<div class="loadable-content" ng-cloak ng-transclude ng-show="loadable === 'false'"> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment