javascript - How I convert this jQuery function to AngularJS Directive? -


i have onclick="starttimer({{ $index }},{{ product.time }})" reason databindings doesn't render, have use ng-clickfor rendering values ng-clickno working jquery script

<script>     function starttimer(id, time) {         $("#" + id).next("div").removeclass("claimactive");         $("#" + id).next("div").addclass("claimwait");         $("#" + id).removeclass("timeractive");         $("#" + id).addclass("timerwait");         $("#" + id).next("div").children("a").text("wait");         if (time <= 60) {             if (time < 10) $("#" + id).children("#m").text("0" + time);             else $("#" + id).children("#m").text(time);             $("#" + id).children("#s").text("30");         } else {             if (time < 600) $("#" + id).children("#h").text("0" + time / 60);             else $("#" + id).children("#h").text(time / 60);             $("#" + id).children("#m").text("00");             $("#" + id).children("#s").text("30");         }     }      function checktimers() {         $(".timer").each(function() {             seconds = parseint($(this).children("#h").text()) * 3600 + parseint($(this).children("#m").text()) * 60 + parseint($(this).children("#s").text());             if (seconds > 0) {                 hours = parseint($(this).children("#h").text());                 min = parseint($(this).children("#m").text());                 sec = parseint($(this).children("#s").text());                 if (sec > 0) {                     if (sec > 10) $(this).children("#s").text(sec - 1);                     else $(this).children("#s").text("0" + (sec - 1));                 } else if (min > 0) {                     if (min > 10) $(this).children("#m").text(min - 1);                     else $(this).children("#m").text("0" + (min - 1));                     $(this).children("#s").text(59);                 } else if (hours > 0) {                     if (hours > 10) $(this).children("#h").text(hours - 1);                     else $(this).children("#h").text("0" + (hours - 1));                     $(this).children("#m").text(59);                     $(this).children("#s").text(59);                 }             } else {                 $(this).next("div").removeclass("claimwait");                 $(this).next("div").addclass("claimactive");                 $(this).addclass("timeractive");                 $(this).removeclass("timerwait");                 $(this).next("div").children("a").text("claim");             }         });     }     $(document).ready(function() {         setinterval(checktimers, 1000);     }); </script> 

so need in angularjs directives, don't have idea how add controller

$scope.starttimer = function($index,producttime) {};


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -