ng-csv icon indicating copy to clipboard operation
ng-csv copied to clipboard

JSON/JS array format

Open ORESoftware opened this issue 7 years ago • 3 comments

Looking forward to using this module!

What's missing in the docs (IMO) is the format of the array - there are several different potential array formats.

I can try to figure this out, but it would best if this were explicitly stated, all we need is a couple elements in the array and we will get the idea so it should fit easily in the README.md file, thx

ORESoftware avatar Mar 09 '17 23:03 ORESoftware

in other words, I am looking for:

 $scope.getArray = function(){

      return [];  // what format is the array supposed to have? :)

    };

ORESoftware avatar Mar 09 '17 23:03 ORESoftware

so I tried this:

   $scope.getArray = function () {

      return [
        {
          a: 'b',
          c: 'd',
          x: 'e'
        },
        {
          a: 'v',
          c: 'r',
          x: 't'
        }];

    };

and I basically get:

b,d,e
v,r,t

so that seems to work, but I wish the headers would be inferred

ORESoftware avatar Mar 09 '17 23:03 ORESoftware

if you use the csv-label directive then the keys will be the header row of the csv file.

csv-label: Defines whether or not using keys as csv column value (default is false).

davidamitchell avatar Apr 02 '17 21:04 davidamitchell