title: How to use papa-parse-angular2
body: <p>Want to use <a href="https://www.npmjs.com/package/papa-parse-angular2" rel="noreferrer">papa-parse-angular2</a> to convert CSV to JSON. Didn't find any example so I do it like this.</p>
  
  <blockquote>
    <p>app.module.ts</p>
  </blockquote>
  
  <pre><code>import {CSVService} from 'papa-parse-angular2';
  @NgModule({
  providers: [
  CSVService, ...
  </code></pre>
  
  <blockquote>
    <p>xx.component.ts</p>
  </blockquote>
  
  <pre><code>constructor( private csvService: CSVService, ...
  private x1() {
      let file = ...;
      this.csvService.parse(file, {
          complete: function(results) {
            // take results.data
          }
        });
  </code></pre>
  
  <p>No build issue. But when run it, got following error.
  <a href="https://i.stack.imgur.com/ctwNP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ctwNP.png" alt="enter image description here"></a></p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'length' of undefined
      at CSVHandler.guessHeaders (vendor.bundle.js:105749)
      at CSVHandler.formHeaders (vendor.bundle.js:105734)
      at CSVHandler.setHeaders (vendor.bundle.js:105761)
      at vendor.bundle.js:64297
      at ZoneDelegate.invoke (vendor.bundle.js:137052)
      at Object.onInvoke (vendor.bundle.js:4532)
      at ZoneDelegate.invoke (vendor.bundle.js:137051)
      at Zone.run (vendor.bundle.js:136812)
      at NgZone.run (vendor.bundle.js:4401)
      at vendor.bundle.js:64293
      at SafeSubscriber.schedulerFn [as _next] (vendor.bundle.js:4247)
      at SafeSubscriber.__tryOrUnsub (vendor.bundle.js:14620)
      at SafeSubscriber.next (vendor.bundle.js:14569)
      at Subscriber._next (vendor.bundle.js:14509)
      at Subscriber.next (vendor.bundle.js:14473)
      at EventEmitter.Subject.next (vendor.bundle.js:15308)
      at EventEmitter.emit (vendor.bundle.js:4221)
  </code></pre>
  
  <p>No idea on how to fix. Or other libs to convert CSV to JSON in angular 4? Appreciate any help.</p>