AngularJS onclick Polling Spring MVC

AngularJS onclick Polling Spring MVC

AngularJS provide $timeout service which can be use to refresh data on client page. For this demo we will use Spring MVC framework on server side and from client page we will make request to the server on every second. Every request server will return random integer value and we will put this value on client page.

  • Sample maven project structure:

AngularJS onclick Polling Spring MVC

  • index.jsp:

  • : Server side Spring MC controller class where client will make request and it will return random integer data in response:

  • Output:

AngularJS onclick Polling Spring MVC

  • For more details $timeout service please visit AngularJS API here

download  Download project:  AngularJSPolling

4 thoughts on “AngularJS onclick Polling Spring MVC

      • Thanks for replying to my question, I don’t understand what is promise, I added this function in the controller :

        $scope.cancelFunction = function() {

        and a cancel button :

        Click button to cancel polling from server

        Thanks, your help is appreciated.

Leave a Reply

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

I am not Robot *