AngularJS Polling Spring MVC example

AngularJS Polling Spring MVC example

In this example you will see how to use polling in AngularJS. AngularJS provide service $timeout which is wrapper for “window.setTimeout”. When calling $timeout service it return value is promise. If you want to cancel timeout request then call $timeout.cancel(promise)

Usage:
$timeout([fn], [delay], [invokeApply]);

  • Sample maven project final screen shot:

AngularJS Polling Spring MVC example

  • index.jsp:

  • AngularJSPollController.java – When call comes to the server return random integer value just to show up call goes to the server and data is getting refreshed:

  • Output:

AngularJS Polling Spring MVC example

  • For more information on $timeout please visit AngularJS API here

download  Download project:  AngularJSPolling

Leave a Reply

Your email address will not be published. Required fields are marked *