Skip to content

Instantly share code, notes, and snippets.

@mbalex99
Created June 13, 2013 16:08
Show Gist options
  • Save mbalex99/5774963 to your computer and use it in GitHub Desktop.
Save mbalex99/5774963 to your computer and use it in GitHub Desktop.
Loadable Directive for Angularjs
'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);
}
});
}
};
});
<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