I have a page with some tabs and each tab has large amount of angularjs bindings.This is sample page where i am facing issue.Each tabs take about 10 seconds to render.
You can make custom directive for each li example loading-counter , then add dependency service which will hold counter, and in each directive inside link function you can call
var app = angular.module('app', []);
app.controller('List', function(LoadingCounter) {
this.tabs = [{
title: "Test tab",
url: "http://google.sk"
}, {
title: "Test tab",
url: "http://google.sk"
}, {
title: "Test tab",
url: "http://google.sk"
}]
this.LoadingCounter = LoadingCounter;
});
app.directive('spinningLoader', function(LoadingCounter) {
return {
restrict: 'A',
scope: {
max: "="
},
link: function(scope) {
LoadingCounter.updateCounter(scope.max);
}
}
});
app.factory('LoadingCounter', function($timeout) {
var service = {};
service.currentCounter = 0;
service.finished = false;
service.updateCounter = function(max) {
service.currentCounter++;
if (service.currentCounter == max) {
//example timeout
$timeout(function() {
service.finished = true;
}, 2000);
}
}
service.isFinished = function() {
return service.finished;
}
return service;
});
.hidden {
display: none;
}
Loading
- {{tab.title}}