214
214
'DT_DEFAULT_OPTIONS' ,
215
215
'$timeout' ,
216
216
'DT_LAST_ROW_KEY' ,
217
- 'DT_HAS_NG_ROWS' ,
218
- function ( $http , DT_DEFAULT_OPTIONS , $timeout , DT_LAST_ROW_KEY , DT_HAS_NG_ROWS ) {
219
- var hasNgRows = false ;
217
+ function ( $http , DT_DEFAULT_OPTIONS , $timeout , DT_LAST_ROW_KEY ) {
220
218
var $loading = angular . element ( '<h3>Loading...</h3>' ) ;
221
219
var _doRenderDataTable = function ( $elem , options ) {
222
220
// Add $timeout to be sure that angular has finished rendering before calling datatables
227
225
$elem . dataTable ( options ) ;
228
226
} , 0 , false ) ;
229
227
} ;
230
- var _renderDataTableIfNoNgRows = function ( $elem , options ) {
231
- // Mmh ugly... I don't know how to do it in another way...
232
- // Waiting in case we have ng rows
233
- $timeout ( function ( ) {
234
- if ( ! hasNgRows ) {
235
- _doRenderDataTable ( $elem , options ) ;
236
- }
237
- } , 100 ) ;
228
+ var _renderDataTableIfNoNgRows = function ( $elem , options , isNgDisplay ) {
229
+ if ( ! isNgDisplay ) {
230
+ _doRenderDataTable ( $elem , options ) ;
231
+ }
238
232
} ;
239
233
return {
240
234
restrict : 'A' ,
241
235
scope : {
242
236
dtOptions : '=' ,
243
- dtColumns : '='
237
+ dtColumns : '=' ,
238
+ datatable : '@'
244
239
} ,
245
240
link : function ( $scope , $elem ) {
246
241
// Display loading
268
263
}
269
264
}
270
265
}
271
- _renderDataTableIfNoNgRows ( $elem , options ) ;
272
- $scope . $on ( DT_HAS_NG_ROWS , function ( ) {
273
- hasNgRows = true ;
274
- } ) ;
266
+ var isNgDisplay = $scope . datatable && $scope . datatable === 'ng' ;
267
+ _renderDataTableIfNoNgRows ( $elem , options , isNgDisplay ) ;
275
268
$scope . $on ( DT_LAST_ROW_KEY , function ( ) {
276
269
_doRenderDataTable ( $elem , options ) ;
277
270
} ) ;
281
274
] ) . directive ( 'dtRows' , [
282
275
'$rootScope' ,
283
276
'DT_LAST_ROW_KEY' ,
284
- 'DT_HAS_NG_ROWS' ,
285
- function ( $rootScope , DT_LAST_ROW_KEY , DT_HAS_NG_ROWS ) {
277
+ function ( $rootScope , DT_LAST_ROW_KEY ) {
286
278
return {
287
279
restrict : 'A' ,
288
280
link : function ( $scope ) {
289
- $rootScope . $broadcast ( DT_HAS_NG_ROWS ) ;
290
281
if ( $scope . $last === true ) {
291
282
$rootScope . $broadcast ( DT_LAST_ROW_KEY ) ;
292
283
}
486
477
* Add option to "oColReorder" option
487
478
* @param key the key of the option to add
488
479
* @param value an object or a function of the function
489
- * @param { DTOption } the options
480
+ * @return { DTOptions } the options
490
481
*/
491
482
this . withColReorderOption = function ( key , value ) {
492
483
if ( angular . isString ( key ) ) {
698
689
'datatables.directive' ,
699
690
'datatables.factory' ,
700
691
'datatables.bootstrap'
701
- ] ) . value ( 'DT_LAST_ROW_KEY' , 'datatable:lastRow' ) . value ( 'DT_HAS_NG_ROWS' , 'datatable:hasNgRow' ) ;
692
+ ] ) . value ( 'DT_LAST_ROW_KEY' , 'datatable:lastRow' ) ;
702
693
} ( angular ) ) ;
0 commit comments