Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 54b4350

Browse files
committed
- we had a problem where we have a directive created for our spinner, but angular-datatables only works with raw HTML
- pass $scope into showLoading(), which passes to DTLoadingTemplate.compileHtml(), which can then compile the HTML which can contain directives - DTLoadingTemplate can then be overridden, with a custom html variable that can now contain directives
1 parent ecba70d commit 54b4350

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

dist/angular-datatables.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function dataTable($q, $http, DTRendererFactory, DTRendererService, DTPropertyUt
4747
angular.forEach(['dtColumns', 'dtColumnDefs', 'dtOptions'], function(tableDefField) {
4848
$scope[watchFunction].call($scope, tableDefField, handleChanges, true);
4949
});
50-
DTRendererService.showLoading($elem);
50+
DTRendererService.showLoading($elem, $scope);
5151
ctrl.render($elem, ctrl.buildOptionsPromise(), _staticHTML);
5252
};
5353
}
@@ -411,10 +411,16 @@ function dtColumnDefBuilder(DTColumnBuilder) {
411411
}
412412
dtColumnDefBuilder.$inject = ['DTColumnBuilder'];
413413

414-
function dtLoadingTemplate() {
415-
return {
416-
html: '<h3 class="dt-loading">Loading...</h3>'
414+
function dtLoadingTemplate($compile) {
415+
var template = {};
416+
417+
template.html = '<h3 class="dt-loading">Loading...</h3>';
418+
419+
template.compileHtml = function ($scope) {
420+
return $compile(angular.element(template.html))($scope);
417421
};
422+
423+
return template;
418424
}
419425

420426
'use strict';
@@ -690,8 +696,8 @@ function dtRendererService(DTLoadingTemplate) {
690696
};
691697
return rendererService;
692698

693-
function showLoading($elem) {
694-
var $loading = angular.element(DTLoadingTemplate.html);
699+
function showLoading($elem, $scope) {
700+
var $loading = angular.element(DTLoadingTemplate.compileHtml($scope));
695701
$elem.after($loading);
696702
$elem.hide();
697703
$loading.show();
@@ -794,7 +800,7 @@ function dtDefaultRenderer($q, DTRenderer, DTRendererService, DTInstanceFactory)
794800

795801
function rerender() {
796802
_oTable.destroy();
797-
DTRendererService.showLoading(_$elem);
803+
DTRendererService.showLoading(_$elem, $scope);
798804
render(_$elem);
799805
}
800806
return renderer;
@@ -874,7 +880,7 @@ function dtNGRenderer($log, $q, $compile, $timeout, DTRenderer, DTRendererServic
874880

875881
function rerender() {
876882
_destroyAndCompile();
877-
DTRendererService.showLoading(_$elem);
883+
DTRendererService.showLoading(_$elem, $scope);
878884
$timeout(function() {
879885
var result = DTRendererService.hideLoadingAndRenderDataTable(_$elem, renderer.options);
880886
_oTable = result.DataTable;
@@ -963,7 +969,7 @@ function dtPromiseRenderer($q, $timeout, $log, DTRenderer, DTRendererService, DT
963969

964970
function rerender() {
965971
_oTable.destroy();
966-
DTRendererService.showLoading(_$elem);
972+
DTRendererService.showLoading(_$elem, _$scope);
967973
render(_$elem, _$scope);
968974
}
969975

@@ -1105,7 +1111,7 @@ function dtAjaxRenderer($q, $timeout, DTRenderer, DTRendererService, DT_DEFAULT_
11051111
options.bDestroy = true;
11061112
if (_oTable) {
11071113
_oTable.destroy();
1108-
DTRendererService.showLoading(_$elem);
1114+
DTRendererService.showLoading(_$elem, _$scope);
11091115
// Empty in case of columns change
11101116
$elem.empty();
11111117
}

0 commit comments

Comments
 (0)