0

I have inherited a site and I am trying to complete a final part. On all other controllers I have added a variation of

$timeout(function(){  //Issue is this doesn't seem to timeout...
                     $scope.rTapTopNumbersContainer = document.getElementById('rtap-quote-summary');
                     rTapNotifyDOMChange($scope.rTapTopNumbersContainer);
                }, 100); 

but on this final controller I cannot seem to add this code anywhere in the controller without the angular code not working, or where I have it at the moment, timeout. I need the timeout to fire to then update the HTML DOM.

If I put it in .success the timeout doesn't seem to work. Where can I put this code or how can I call this code after the $http has fired?

app.controller('summary', ['$scope', '$http', function($scope, $http, $timeout) {

var init = function () {
    $http({
            method: 'GET',
            url: $scope.api + 'sites/site/?title=' + $scope.site 
        }).
            success(function(data, status, headers, config) {

            ...assign vars to scope etc...

            $timeout(function(){  //Issue is this doesn't seem to timeout...
                 $scope.rTapTopNumbersContainer = document.getElementById('rtap-summary');
                 rTapNotifyDOMChange($scope.rTapTopNumbersContainer);
            }, 100); 

        }).
            error(function(data, status, headers, config) {
        });
    }
init();
}]);
3
  • 1
    Are you sure it's not in the error part? Commented Nov 13, 2014 at 15:29
  • 1
    you didn't import timeout correctly Commented Nov 13, 2014 at 15:38
  • also, if you don't mind me asking, why do you need timeout? Commented Nov 13, 2014 at 15:41

1 Answer 1

2

Maybe you didn't import $timeout correctly?

app.controller('summary', ['$scope', '$http', '$timeout', function($scope, $http, $timeout) { // twice
//                           1.         2.        3.                 1.      2.       3.

}]);
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.