0
votes

I want to display the following array in an ngGrid

$scope.pathinfo = ["28.86 GB left on dir1","28.86 GB left on dir2"]

My controller looks like this:

$scope.restorePathGridOptions = { data: '$scope.pathInfo',
                       columnDefs: [
                            {field: 'entry', displayName: 'Free Space for paths'}
                        ]
                    }

And this is my HTML:

<div id="RestorepathsGrid" class="gridStyle" ng-grid="restorePathGridOptions">

I am assuming 'entry' is data value of array at indices 0 and 1.

But the grid does not show up at all.

Any ideas why?

2

2 Answers

0
votes

data: '$scope.pathInfo'

$scope is not needed here.

Also, if you want field entry as in your example, then you have to use array of objects

0
votes

Use an array of objects instead of an array:

$scope.pathinfo = [{entry: "28.86 GB left on dir1"}, {entry: "28.86 GB left on dir2"}]

Notice that the field name of the objects in $scope.pathinfo should match field name in columnDefs. This should solve your problem.