-1
@Controller
public class HelloController {
    @RequestMapping(value="/here", method=RequestMethod.POST)
    public String display( Model m)
    {   
      m.addAttribute("msg", "Hello from controller: ");
      return "NewFile";
    }
}
Andrew
  • 26,706
  • 9
  • 85
  • 101

1 Answers1

0

First of all you will have to return the object you want to get in Angularjs. You can use Jackson to map your object to Json. And then just call your end point from Angular and build a Object from the Json in angular.

Here is a link how to load json in angularjs: How to load json into my angular.js ng-model?

If you have the following JSON

[{ "text":"learn angular", "done":true },
 { "text":"build an angular app", "done":false},
 { "text":"something", "done":false },
 { "text":"another todo", "done":true }]

You can load it like this

var App = angular.module('App', []);

App.controller('TodoCtrl', function($scope, $http) {
  $http.get('todos.json')
       .then(function(res){
          $scope.todos = res.data;                
        });
});

The get method returns a promise object which first argument is a success callback and the second an error callback.

When you add $http as a parameter of a function Angular does it magic and injects the $http resource into your controller.

Willem
  • 992
  • 6
  • 13