1

I am using the timer found here:

http://siddii.github.io/angular-timer/

I am attempting to connect to my firebase and obtain a start_time. The timestamp is correct. I believe that it has to do with the fact that the timer is starting before the firebase info is injected into the view, so I've tried to account for that in the controller:

firebase.$loaded().then(function() {
    function startTimer(){
        $scope.$broadcast('timer-start');
        $scope.timerRunning = true;
    };
    startTimer();
});

My view looks like:

<timer autostart="false" start-time="firebase.table26.seated_time" >{{hours}}:{{minutes}}:{{seconds}}</timer>

It does appear to be waiting until firebase loads appropriately, but the timer just starts at 0. Assigning the variable to start-time manually works...and calling {{firebase.table26.seated_time}} from the view also works as expected.

1
  • You should start with some due diligence: verify that seated_time is set to something other than 0 (and is not a string), demonstrate how you've verified that it waits until Firebase loads, et al. Debuggers and breakpoints would be a great utility here. Commented Sep 5, 2014 at 16:04

1 Answer 1

1

Adding a timeout, even of 1ms fixes this issue. I'm not sure if it is the best-case at this point, but it did fix the problem for me:

firebase.$loaded().then(function() {
    $timeout(function () {
        function startTimer(){
            $scope.$broadcast('timer-start');
            $scope.timerRunning = true;
        };
        startTimer();
    }, 1);
});
Sign up to request clarification or add additional context in comments.

Comments

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.