title: angularjs multiple countdown
body: <p>Im in need to make a countdown like this:</p>
  
  <pre><code>&lt;div  class="countdown" countdown="1482400417"&gt;00:10:02&lt;/div&gt;
  </code></pre>
  
  <p>where the countdown attribute is the time when its finished. the difference is showed in hours:minutes:secs , and it updates each second.</p>
  
  <p>How would i do this in angularjs, when i have multiple countdowns like that?</p>
  
  <p>I did a little digging, and i found something that did something simular, but i couldnt understand the code. So ill post the code i found:</p>
  
  <pre><code>Travian.Directive.countdown = function(a) {
      return function(c, b, l) {
          function g() {
              if ("undefined" != typeof a.K()) {
                  h = b.attr("countdown");
                  var c = h - a.K();
                  if (0 &gt; c || isNaN(c)) {
                      return Travian.tick.unbind(e), e = null, b.text(
                          la(0)), !1
                  }
                  var g = "";
                  l.showDaysLimit &amp;&amp; c &gt;= l.showDaysLimit ? (c = Math
                      .round(c / 86400), c == f ? g = m : (g =
                          Travian.translate("ForDays", {
                              x: c
                          }), f = c)) : g = la(c, l.countdownShort &amp;&amp;
                      c &lt; l.countdownShort);
                  m != g &amp;&amp; (m = g, b.text(g))
              }
          }
          var h, e = null,
              m = "",
              f = 0;
          l.showDaysLimit &amp;&amp; c.$on("newTranslation", function() {
              f = 0
          });
          l.$observe("countdown", function(a) {
              "undefined" != typeof a &amp;&amp; null == e &amp;&amp; (e =
                  Travian.tick.bind(g))
          });
          b.bind("$destroy", function() {
              Travian.tick.unbind(e)
          })
      }
  };
  
  
  
    Travian.tick = new function() {
      var a = {};
      (function B() {
        window.setTimeout(B, 100);
        var b = {}, c;
        for(c in a) {
          a.hasOwnProperty(c) &amp;&amp; "function" === typeof a[c] &amp;&amp; (a[c](), b[c] = a[c])
        }
        a = b
      })();
      return{bind:function(b, c) {
        "function" === typeof b &amp;&amp; (c = b, b = na("tick"));
        c();
        a[b] = c;
        return b
      }, unbind:function(b) {
        a[b] = null
      }}
    };
  </code></pre>