In the following directive, I do a pretty long running operation, so I want to display a loading spin during that time. I've used ng-show and a isLoading variable on the scope of the directive. However the spinner never shows although isLoading is set to true.
What's wrong with my code ?
angular.module('shared.directives').directive("xmlVisualizer", ['$rootScope', function ($rootScope) {
return {
restrict: 'E',
template: '<div ng-show="isLoading" class="center span10"><i class="icon-spinner icon-6x">chargement du fichier...</i> </div> <div class="center span10" ng-show="!isLoading"> <h4>Détail du fichier {{title}}</h4> <pre id="test" class="prettyprint"></pre></div>',
scope: {
model: '=',
title: '='
},
link: function (scope, element, attrs) {
if (scope.model) {
scope.isLoading = true;
scope.xml = vkbeautify.xml(scope.model);
$("#test").text(scope.xml);
$("#test").html(prettyPrintOne($("#test").html(), 'xml'));
scope.isLoading = false;
}
}
}
}]);