(function() { "use strict"; angular.module("raz") .component('lcmScopeSequence', { templateUrl: '/js/angular/literacy-curriculum-map/routes/lcm-scope-sequence.html', controller: 'lcmScopeSequenceController', bindings: { gradeId: '<' } }) .controller("lcmScopeSequenceController", ['lcmGradeService', 'lcmGradeFolderIds', '$scope', function (lcmGradeService, lcmGradeFolderIds, $scope) { var ctrl = this; ctrl.isPending = false; var tablesRendered = 0; ctrl.$onInit = function () { lcmGradeService.setCurrentGradeId(ctrl.gradeId); setUnits(); }; ctrl.isLoading = function () { return ctrl.isPending; }; $scope.$on('SSTableLastElem', function (event) { tablesRendered++; if (tablesRendered === ctrl.units.length) { ctrl.isPending = false; } }); function setUnits() { ctrl.isPending = true; lcmGradeService.getLCMSSUnitsTreeById(lcmGradeFolderIds['grade_' + ctrl.gradeId]['folder_id']) .then(function (response) { ctrl.units = response['children']; }); } }]); })();