$timeout is Angular's wrapper for window.setTimeout.
2
votes
3answers
332 views
How do I use $timeout service in a Directive?
Basically, I want to measure the width of the element after angular has manipulated the DOM. So I would like to use $timeout for that, but it keeps getting me errors.
HTML
<div ng-app="github"&...
0
votes
2answers
36 views
Create automatic javascript queue with time out to shift items
What I'm trying to achieve is very straight forward but I'm confused. I'm trying to make a queue that holds hospital patients, they will be logged in the system, added to an array (FIFO) and then ...
2
votes
4answers
60 views
Trigger ng-show after delay
I want to make a div appear 10s after the page has loaded. I would like to use angular.
<div class="appearingitem" ng-show="timeduration"></div>
Any ideas how i might accomplish this? ...
1
vote
3answers
457 views
How can clear $timeout in angularjs
I have this code for image slider and next prev and auto change the image function
scope.next = function () {
scope.currentIndex < scope.images.length - 1 ? scope.currentIndex++ : scope....
3
votes
2answers
207 views
Simulate the passage of time in protractor?
I have a few spots where things happen in the UI on a delay using $timeout or $interval. Here's a simplified example:
Controller code:
$timeout(function() {
$scope.showElement = true;
}, 10000);
...
2
votes
1answer
839 views
AngularJS: avoid using $timeout to wait for image loading completion
I'm trying to create my own image carousel as an angularjs directive; I want to keep it as lightweight and unopinionated as possibile, so I thought I'd just create a <carousel></carousel> ...
2
votes
1answer
524 views
Cancel a resource request in angular
I am new to angular so I need detailed solution to this question. I have seen a lot of answers but not according to my situation.
I have a service:
function ticketService($resource, globals) {
...
0
votes
2answers
646 views
Is any event “on $scope digest finished” or “on view refreshed” in Angular.js?
I'm doing an AJAX request for data that is used in the view for generation of a list. I need to know when the $scope is updated and when the view is rendered after a successful response received, so ...
0
votes
1answer
473 views
AngularJS: $timeout within directive's controller using “this”
Not sure if everything is wired up here correctly. The objective is to call the nextSlide function, for it to change the class, wait a second, then incrament the current picture by 1, and then change ...
1
vote
1answer
4k views
AngularJS $timeout sometimes works sometimes doesn't
I'm experiencing some problems with AngularJS and $timeout.
I need to run some code, after the page is loaded. Http.get() loads items and ng-repeat displays them in table. Then I need to run the code ...
0
votes
0answers
477 views
Unit testing services with mocha (no e2e test) on AngularJS with $timeout never finishes
I have a service that needs to call the database through AJAX and this is the test for it:
describe 'Cep service', ->
cep = undefined
$timeout = undefined
beforeEach(module('cep'))
...
0
votes
0answers
81 views
Why do I have to use $timeout to update variables in Angular?
I have a directive in a directive. In the deepest directive I have this:
directive B:
scope.onChange = function () {
scope.ngModel = scope.selectedItem.Id;
$timeout(function () {
...
1
vote
1answer
321 views
AngularJS - Change Tracking
I'm new to AngularJS. I'm looking at using the $timeout service. I've read that one of the reasons for using $timeout over the JavaScript setTimeout function is because changes to variables in the $...
0
votes
0answers
133 views
$timeout not firing when window isn't in focus?
As part of learning AngularJS, I decided to rewrite Cookie Clicker using it. I have a controller set up and it has (among other things) $scope.Cookies, $scope.CPS (to represent the cookies per second),...
1
vote
1answer
3k views
passing objects to $timeout
Is there something special I need to do to access objects inside $timeout functions?
I get errors saying routes is undefined when I try and access it in the $timeout function, but outside the $...
0
votes
1answer
529 views
AngularJS cannot seem to take a variable duration for a $timeout
I am trying to implement a function within the controller which will be incharge of showing various notification to the user.
the problem is that I want the duration to be a function parameter, and ...
9
votes
1answer
4k views
What's the right way to wait for ng-init values to be set?
I have an "ng-init" directive in my HTML that initializes the value of "data.id" in my Angular.js data model. Let's say for now that I can't change how this works.
Now, I want to make an HTTP request ...
145
votes
2answers
43k views
AngularJS : $evalAsync vs $timeout
I've been using AngularJS for a little while now, and have found the need to use $timeout every once in a while (Seems to usually be to init a jQuery plugin).
Recently, I've been trying to get a ...
1
vote
1answer
2k views
AngularJS: Why and when calling $timeout is required?
Live Demo
I created a confirmationDialogHeader directive which is used like so:
<ul>
<li ng-repeat="item in items">
{{item}}
<button class="btn btn-mini"
...
2
votes
1answer
2k views
angularjs save changes after digest has finished
I think this might be quite common use-case with any angular app. I am simply watching some objects on my scope that are changed as part of several digest cycles. After digesting them (changing their ...