File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,27 +10,37 @@ var buildChartDirective = function ( chartType ) {
1010 } ,
1111 link : function ( scope , element , attrs ) {
1212
13- var options = { } ;
14- if ( scope . options ) {
15- options = scope . options ;
16- }
13+ var options = { } ;
14+ if ( scope . options ) {
15+ options = scope . options ;
16+ }
1717
18- var span = document . createElement ( 'span' ) ;
19- span . textContent = scope . data . join ( ) ;
18+ var span = document . createElement ( 'span' ) ;
19+ span . textContent = scope . data . join ( ) ;
20+
21+ if ( ! attrs . class ) {
22+ span . className = "" ;
23+ } else {
24+ span . className = attrs . class ;
25+ }
2026
21- if ( ! attrs . class ) {
22- span . className = "" ;
23- } else {
24- span . className = attrs . class ;
25- }
27+ if ( element [ 0 ] . nodeType === 8 ) {
28+ element . replaceWith ( span ) ;
29+ } else {
30+ element [ 0 ] . appendChild ( span ) ;
31+ }
32+
33+ jQuery ( span ) . peity ( chartType , options ) ;
34+
35+ var watcher = scope . $watch ( 'data' , function ( ) {
36+ span . textContent = scope . data . join ( ) ;
37+ jQuery ( span ) . change ( ) ;
38+ } )
2639
27- if ( element [ 0 ] . nodeType === 8 ) {
28- element . replaceWith ( span ) ;
29- } else {
30- element [ 0 ] . appendChild ( span ) ;
31- }
40+ scope . $on ( '$destroy' , function ( ) {
41+ watcher ( ) ;
42+ } ) ;
3243
33- jQuery ( span ) . peity ( chartType , options ) ;
3444
3545 }
3646 } ;
You can’t perform that action at this time.
0 commit comments