1

Currently when the dome reach the line below this function returnCookie() is run immediately.

<div class="" ng-init="test.name=returnCookie()"> 

I would like to delay it for a few seconds maybe something like this

<div class="" ng-init="test.name=Delay(1000,returnCookie())">

Delaying 1000ms before executing returnCookie().

I do note not want to use $timeout(function() {},1000) inside of the function, as this function only needs to delay in this case while it's use on other page without needing to delay.

Please assist, Thanks.

nicker
  • 477
  • 2
  • 6
  • 20
  • Could you not create a function `delayCookieReturn()` which simply calls `$timeout(returnCookie, 1000)` and set your `ng-init` to that? That way you don't have to alter `returnCookie`. – Mourndark Jul 01 '16 at 09:33
  • you could try to modify the directive provided in this [topic](http://stackoverflow.com/questions/21121460/angular-directive-encapsulating-a-delay-for-ng-change) to use it with ng-init – Max Novich Jul 01 '16 at 09:50

0 Answers0