I am working on one project which is based on EJB, AngularJS, restful web services and JPA.
I have created a web service and it will return data from database in JSON format to client.
At client side, I want to display this JSON data in ng-grid but the data not getting displayed.
Below is my code:
JS code
dashboard.controller('MainController', function($scope, $http) {
$http.get('http://localhost:8080/WebApplication2/rest/testentity').
success(function(data) {
$scope.mydata = data;
console.log("data response : " + $scope.mydata);
});
$scope.gridOptions = {
data: $scope.mydata,
enableRowSelection: false,
enableCellEditOnFocus: true,
multiSelect: false,
columnDefs: [{
field: 'id',
displayName: 'id',
enableCellEdit: false
},
{
field: 'testname',
displayName: 'testname',
enableCellEdit: false
},
{
field: '',
displayName: 'Save',
enableCellEdit: false,
cellTemplate: '<button id="editBtn" type="button" ng-click="saveItem(row.entity.testname)" >Save</button>'
}
]
};
});
In the console, it will display proper data
console Output
data response : [object Object],[object Object]
Please suggest what is wrong with my code.