Just started learning AngularJS and everything was going smoothly until I hit a roadblock...
I have been struggling to display the JSON data returned from my REST service call. While hard-coding a data array in my controller works fine, displaying the actual JSON data has been challenging.
This is the current code snippet...
Web page-
<div ng-controller="ExceptionLogDataController">
<div ui-grid="gridOptions" class="vertexGrid"></div>
</div>
ExceptionLogDataController-
... ...I've confirmed that the REST call returns valid JSON data using Postman, so the issue must be in my frontend code.
Making some progress...
Successfully retrieved the JSON object and attempting to display it with the following code...
$scope.data = [];
$scope.gridOptions = {
enableSorting: true,
data: 'data',
};
ExceptionLogDataService() //Call to Service that returns json object
.then(function (data) {
$scope.data = data;
$scope.gridOptions.data = $scope.data;
console.log($scope.data);
}
Here's the JSON object returned from the console.log call...
Object { DataId: 1074, SourceDateTime: "2016-01-19T13:29:01.2512456-05:00", MessageText: "There is an error in XML document (…", IsDirty: false, StatusList: Object, FileName: "D:\ProdMonitorSiteDev\ErrorFiles\…", GenJIRATicket: false, MessageCount: 1, MachineName: "VERTEXCUTIL01", AppDomainName: "", 2 more… }
Encountering this error...
Error: newRawData.forEach is not a function