@@ -14,7 +14,7 @@ function updateTitle(td, th) {
14
14
function colspan ( td ) {
15
15
var colspan = td . getAttributeNode ( 'colspan' ) ;
16
16
return colspan ? parseInt ( colspan . value ) : 1 ;
17
- }
17
+ }
18
18
19
19
function wtResponsiveTable ( ) {
20
20
return {
@@ -25,7 +25,7 @@ function wtResponsiveTable() {
25
25
var headers = getHeaders ( $element [ 0 ] ) ;
26
26
if ( headers . length ) {
27
27
var row = td . parentElement ;
28
- var headerIndex = 0 ;
28
+ var headerIndex = 0 ;
29
29
var found = Array . prototype . some . call ( row . querySelectorAll ( 'td' ) , function ( value , index ) {
30
30
if ( value === td ) {
31
31
return true ;
@@ -40,21 +40,33 @@ function wtResponsiveTable() {
40
40
}
41
41
} ,
42
42
compile : function ( element , attrs ) {
43
- attrs . $addClass ( 'responsive' ) ;
44
- var headers = getHeaders ( element [ 0 ] ) ;
45
- if ( headers . length ) {
46
- var rows = element [ 0 ] . querySelectorAll ( 'tbody > tr' ) ;
47
- Array . prototype . forEach . call ( rows , function ( row ) {
48
- var headerIndex = 0 ;
49
- Array . prototype . forEach . call ( row . querySelectorAll ( 'td' ) , function ( value , index ) {
50
- if ( ! value . getAttributeNode ( 'responsive-dynamic' ) ) {
51
- var th = value . parentElement . querySelector ( 'th' ) || headers . item ( headerIndex ) ;
52
- updateTitle ( value , th ) ;
53
- }
43
+ function apply ( ) {
44
+ var headers = getHeaders ( element [ 0 ] ) ;
45
+ if ( headers . length ) {
46
+ var rows = element [ 0 ] . querySelectorAll ( 'tbody > tr' ) ;
47
+ Array . prototype . forEach . call ( rows , function ( row ) {
48
+ var headerIndex = 0 ;
49
+ Array . prototype . forEach . call ( row . querySelectorAll ( 'td' ) , function ( value , index ) {
50
+ if ( ! value . getAttributeNode ( 'responsive-dynamic' ) ) {
51
+ var th = value . parentElement . querySelector ( 'th' ) || headers . item ( headerIndex ) ;
52
+ updateTitle ( value , th ) ;
53
+ }
54
54
55
- headerIndex += colspan ( value ) ;
55
+ headerIndex += colspan ( value ) ;
56
+ } ) ;
56
57
} ) ;
57
- } ) ;
58
+ }
59
+ }
60
+
61
+ attrs . $addClass ( 'responsive' ) ;
62
+ if ( Array . prototype . some . call ( element . find ( 'th' ) , function ( it ) {
63
+ return it . getAttributeNode ( 'ng-repeat' ) || it . getAttributeNode ( 'data-ng-repeat' )
64
+ } ) ) {
65
+ setTimeout ( function ( ) {
66
+ apply ( ) ;
67
+ } , 0 ) ;
68
+ } else {
69
+ apply ( ) ;
58
70
}
59
71
}
60
72
} ;
@@ -66,8 +78,8 @@ function wtResponsiveDynamic() {
66
78
require : '^^wtResponsiveTable' ,
67
79
link : function ( scope , element , attrs , tableCtrl ) {
68
80
var td = element [ 0 ] ;
69
- var th = tableCtrl . getHeader ( td ) ;
81
+ var th = tableCtrl . getHeader ( td ) ;
70
82
updateTitle ( td , th ) ;
71
83
}
72
84
} ;
73
- }
85
+ }
0 commit comments