Body onload AngularJS Spring MVC JSON

Body onload AngularJS Spring MVC JSON

In this demo you will see how to use body onload in AngularJS and populate data from server. For this demo we are using AngularJS with Spring MVC to populate the data in combo box:

AngularJS provides directive ngInit which works as body onload and we will use the same.

  • Final project structure:

Body onload AngularJS Spring MVC JSON

  • index.jsp: You will see in below jsp class we are using data-ng-init=”getPersonDataFromServer()” where it is calling function name getPersonDataFromServer and send request to the server and get back response in JSON format and finally we set data in scope to show in drop down list:

  •  BodyOnLoadController.java:

  • PersonData.java

  • Download and run this sample on tomcat server. Example web page out put will be as below:

2014-10-08 15_48_42-Body onload AngularJS Spring MVC JSON

 

For more information please visit AugularJS API reference here:

download  Download Project:  OnloadAngularJSSpring

Leave a Reply

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