File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed
Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 55
66angular . module ( 'sc.directives' , [ ] ) .
77 directive ( 'moment' , [ '$timeout' , function ( $timeout ) {
8- return {
9- restrict : 'C' ,
10- link : function ( scope , element , attr ) {
11- //$timeout.setTimeout();
8+
9+ return function ( scope , element , attrs ) {
10+ var timeoutId ;
11+
12+ function updateText ( ) {
13+ element . text ( moment ( attrs . moment ) . fromNow ( ) ) ;
1214 }
15+
16+ function updateLoop ( ) {
17+ timeoutId = $timeout ( function ( ) {
18+ updateText ( ) ;
19+ updateLoop ( ) ;
20+ } , 5000 ) ;
21+ }
22+
23+ element . on ( '$destroy' , function ( ) {
24+ $timeout . cancel ( timeoutId ) ;
25+ } ) ;
26+
27+ updateLoop ( ) ;
1328 } ;
1429 } ] ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ <h2>Heartbeats List</h2>
33 < div class ="col-6 col-sm-6 col-lg-4 " ng-repeat ="heartbeat in model ">
44 < div style ="margin: 5px; " ng-class ="{'alert-success': heartbeat.failing == false, 'alert-danger': heartbeat.failing == true} ">
55 < h2 > {{heartbeat.endpoint}}</ h2 >
6- < p > Last Updated At: {{heartbeat.last_heartbeat_sent_at | moment}} </ p >
6+ < p > Last Updated: < span moment =" {{heartbeat.last_heartbeat_sent_at}} " > </ span > </ p >
77 </ div >
88 </ div >
99</ div >
You can’t perform that action at this time.
0 commit comments