npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-csv2

v0.3.9

Published

Simple directive that turns arrays and objects into downloadable CSV files

Downloads

1,242

Readme

ngCsv - Export to CSV using AngularJS

An AngularJS simple directive that turns arrays and objects into downloadable CSV files,

Build Status

Dependencies

  • angular.js (of course!), any version starting with 1
  • angular-sanitize.js, any version starting with 1

How to get it ?

Manual Download

Download the from here

Bower

bower install ng-csv

Npm

npm install ng-csv

CDN

ng-csv is available at cdnjs

Usage

  1. Add ng-csv.min.js to your main file (index.html). please also make sure you're adding angular-sanitize.min.js.

  2. Set ngCsv as a dependency in your module

var myapp = angular.module('myapp', ['ngSanitize', 'ngCsv'])
  1. Add ng-csv directive to the wanted element, example:
<button type="button" ng-csv="getArray" filename="test.csv">Export</button>

ngCsv attributes

  • ng-csv: The data array - Could be an expression, a value or a promise.

  • filename: The filename that will be stored on the user's computer

  • csv-header: If provided, would use this attribute to create a header row

    <button type="button" ng-csv="getArray" csv-header="['Field A', 'Field B', 'Field C']" filename="test.csv">Export</button>
  • csv-column-order: Defines the column order to be set when creating the body of the CSV (may be according to the csv-headers) - use it when you have an array of objects.

  • field-separator: Defines the field separator character (default is ,)

  • decimal-separator: Defines the decimal separator character (default is .). If set to "locale", it uses the language sensitive representation of the number.

  • text-delimiter: If provided, will use this characters to "escape" fields, otherwise will use double quotes as deafult

  • quote-strings: If provided, will force escaping of every string field.

  • lazy-load: If defined and set to true, ngCsv will generate the data string only on demand. See the lazy_load example for more details.

  • add-bom: Add the Byte Order Mark, use this option if you are getting an unexpected char when opening the file on any windows App.

  • charset: Defines the charset of the downloadable Csv file. Default is "utf-8".

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

Examples

You can check out this live example here: https://asafdav.github.io/ng-csv/example/

For lazy load example using promises see this example: https://asafdav.github.io/ng-csv/example/lazy_load.html

Supported Browsers

| Browser | Filenames | | --------------- | ------------- | | Firefox 20+ | Yes | | Chrome 14+ | Yes | | Safari | No | | IE 10+ | Yes |

Bitdeli Badge