0

I'm trying to make a timer in javascript, a very simple one. I wrote a bit of code that should have worked afaik, yet it doesn't, so I did something wrong. I cant figure out what I did wrong. after a second it changes the value of the textbox to NaN.

Here is the code:

<timer countdown='timeBonPlan' interval="1000" >{{days}} Jours, {{hours}}:{{minutes}}:{{seconds}}</timer>

and in my controller

$scope.timeBonPlan =  3765915.979;

i have use parseFoalt but it doesn't work when i set the value in the html page its work

7
  • I had the same problem. Have you tried using double brackets? If not then, look at the code. I think you can pass the service to the controller and set countdown time there. Commented Nov 18, 2015 at 9:42
  • countdown is 2way bound countdownattr: '=countdown', you can set a property on the scope or integer value(special implementation is present for that). So countdown='timeBonPlan' should just work. i think issue was with floating value. please assign integer value Commented Nov 18, 2015 at 9:45
  • what is timer directive? your own? if yes, so - provide code for it, if not provide link for doc Commented Nov 18, 2015 at 10:01
  • no, its an angular directive Commented Nov 18, 2015 at 10:19
  • can you provide link to documentation for this directive? are you sure that this standart angular directive? Where you find this directive? Commented Nov 18, 2015 at 10:21

2 Answers 2

1

I had similar issue, Was able to solve by using ng-if to check if contdown variable exist thus:

<timer ng-if="timeBonPlan" countdown='timeBonPlan' interval="1000" >{{days}} Jours, {{hours}}:{{minutes}}:{{seconds}}</timer>

I hope you find it useful

Sign up to request clarification or add additional context in comments.

Comments

0

You can try appending a + sign like

<timer countdown='+timeBonPlan' interval="1000" >{{days}} Jours, {{hours}}:{{minutes}}:{{seconds}}</timer>

2 Comments

doesn't work but when i make <timer countdown='3348759847.445' interval="1000" >{{days}} Jours, {{hours}}:{{minutes}}:{{seconds}}</timer> it works
you can check value of timeBonPlan in template, maybe you are not getting the value {{ timeBonPlan }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.