I have some JSON data and I want to try using ng-grid with it. Looking at some examples online it does not show how to put the data from an app spot to the grid. So this is what I have so far.
function DataCtrl($scope, Json) {
$scope.Data = Json.query(); // Here we want to query for all Json data
console.log($scope.Data);
};
Does anyone know how to take this array Json.query and have it in an ng-grid?
The examples on the ng-grid site are pretty self explanatory. I am wondering if your issue is returning the data. Your $scope.Data object should have returned Json objects, and once you are sure that you have them, adding them to the grid is very easy.
Below is the basic example code from the ng-grid site:
HTML:
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
</body
Javascript:
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = { data: 'myData' };
});
This is a module for AngularJS, so I would suggest taking a little time to learn it. It is a beautiful framework worth learning. Once you understand the basics of AngularJS, this will probably make more sense.