jeudi 18 février 2016

How can I output an automatic timer using Handlebars / EmberJs?

I've made a function which works as a timer and executes every second. When I console log the output of the function, it works fine, but it doesn't update graphically. This is my code:

In the model:

timer: function(){
   var model = this;
   return setInterval(function(){
      var start = model.get('startTime');
      var end = Date.now();
      var difference = end - start;
      console.log(difference);
      return difference;
 }, 1000);

In handlebars:

{{model.timer}}




Aucun commentaire:

Enregistrer un commentaire