Skip to content

Commit 6ad5e86

Browse files
committed
Version bump
1 parent 0ef8feb commit 6ad5e86

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-csv",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"main": "build/ng-csv.min.js",
55
"dependencies": {
66
"angular": "~1",

build/ng-csv.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ angular.module('ngCsv.services').
130130
arrData = responseData();
131131
}
132132

133+
// Check if using keys as labels
134+
if (angular.isDefined(options.label) && options.label && typeof options.label === 'boolean') {
135+
var labelArray, labelString;
136+
137+
labelArray = [];
138+
angular.forEach(arrData[0], function(value, label) {
139+
this.push(that.stringifyField(label, options));
140+
}, labelArray);
141+
labelString = labelArray.join(options.fieldSep ? options.fieldSep : ",");
142+
csvContent += labelString + EOL;
143+
}
144+
133145
angular.forEach(arrData, function (oldRow, index) {
134146
var row = angular.copy(arrData[index]);
135147
var dataString, infoArray;
@@ -208,7 +220,8 @@ angular.module('ngCsv.directives').
208220
lazyLoad: '@lazyLoad',
209221
addByteOrderMarker: "@addBom",
210222
ngClick: '&',
211-
charset: '@charset'
223+
charset: '@charset',
224+
label: '&csvLabel'
212225
},
213226
controller: [
214227
'$scope',
@@ -239,6 +252,7 @@ angular.module('ngCsv.directives').
239252
};
240253
if (angular.isDefined($attrs.csvHeader)) options.header = $scope.$eval($scope.header);
241254
if (angular.isDefined($attrs.csvColumnOrder)) options.columnOrder = $scope.$eval($scope.columnOrder);
255+
if (angular.isDefined($attrs.csvLabel)) options.label = $scope.$eval($scope.label);
242256

243257
options.fieldSep = $scope.fieldSep ? $scope.fieldSep : ",";
244258

@@ -279,12 +293,13 @@ angular.module('ngCsv.directives').
279293
navigator.msSaveBlob(blob, scope.getFilename());
280294
} else {
281295

282-
var downloadLink = angular.element('<a></a>');
296+
var downloadContainer = angular.element('<div data-tap-disabled="true"><a></a></div>');
297+
var downloadLink = angular.element(downloadContainer.children()[0]);
283298
downloadLink.attr('href', window.URL.createObjectURL(blob));
284299
downloadLink.attr('download', scope.getFilename());
285300
downloadLink.attr('target', '_blank');
286301

287-
$document.find('body').append(downloadLink);
302+
$document.find('body').append(downloadContainer);
288303
$timeout(function () {
289304
downloadLink[0].click();
290305
downloadLink.remove();

build/ng-csv.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-csv",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"main": "build/ng-csv.min.js",
55
"description": "Simple directive that turns arrays and objects into downloadable CSV files",
66
"repository": {

src/ng-csv/services/csv-service.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ angular.module('ngCsv.services').
9898

9999
// Check if using keys as labels
100100
if (angular.isDefined(options.label) && options.label && typeof options.label === 'boolean') {
101-
var encodingArray, labelString;
102-
103-
encodingArray = [];
101+
var labelArray, labelString;
102+
103+
labelArray = [];
104104
angular.forEach(arrData[0], function(value, label) {
105105
this.push(that.stringifyField(label, options));
106-
}, encodingArray);
107-
labelString = encodingArray.join(options.fieldSep ? options.fieldSep : ",");
106+
}, labelArray);
107+
labelString = labelArray.join(options.fieldSep ? options.fieldSep : ",");
108108
csvContent += labelString + EOL;
109109
}
110110

0 commit comments

Comments
 (0)