I am not getting data from Web service's response in angularjs using $http.get method.What cause is this?? It is directly goes to error part.
Web service code:
@GET
@Path("/getEmployeeList")
@Produces(MediaType.APPLICATION_JSON)
public Response getEmployeeList() {
ArrayList<Employee> empList = (ArrayList<Employee>) employeeService.getAllEmployees();
return Response.status(200).entity(empList).build();
}
Angular Js:
<script src="angular.js"></script>
</head>
<body >
<div ng-app="hello">
<h1>Greeting</h1>
<div ng-controller="home" >
<div ng-repeat="a in greeting">
<p>The Id is: {{a.empId}}</p>
<p>The content is: {{a.firstName}}</p>
<p>The content is: {{a.lastName}}</p>
</div>
</div>
</div>
</body>
<script >
var myApp = angular.module('hello', []);
myApp.controller('home',['$scope','$http',function($scope,$http) {
$http.get("http://localhost:8080/restful-jersey-spring-demo/restws/employee/getEmployeeList")
.success(function(data) {
$scope.greeting = data;
}).error(function(data, status, headers, config){
alert("Error")
});
}]);
</script>
</body>
Json Data From Web services: URL:http://localhost:8080/restful-jersey-spring-demo/restws/employee/getEmployeeList
[
{
"empId": 1,
"firstName": "Chirag",
"lastName": "L"
},
{
"empId": 2,
"firstName": "Prashant",
"lastName": "K"
}
]