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:
- 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:
- Download and run this sample on tomcat server. Example web page out put will be as below:
For more information please visit AugularJS API reference here:
Download Project: OnloadAngularJSSpring