I want to make search by AngularJS and spring MVC but the following code didn't work There are no errors in eclipse console or web console
This is Spring MVC Controller
@RequestMapping(value = "app/rest/contacts/search",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Contact> find(@RequestParam(value = "name") String name) {
List<Contact> queryResults = contactRepository.search(name);
return queryResults;
}
This is AngularJS Service
pagingpocApp.factory('Contact', function ($http) {
return {
search: function(name) {
var promise = $http.get('app/rest/contacts/search',{params: {name: name}}).then(function (response) {
return response.data;
});
return promise;
}
}
});
this is AngularJS Controller
pagingpocApp.controller('ContactController', function ($scope, $filter,resolvedContact, Contact) {
$scope.search= function() {
Contact.search($scope.name).then(function(obj) {
console.log(obj)
});
}
});
Html Page
<input ng-model="name">
<input type="submit" ng-click="search()">
@RestControlleryou use@ResponseBody.