angular2 : read a file from local machine
<p>Hi I am new to JavaScript and Angular 2. </p>

<p><strong>I want to read a text file from local machine and show the content on page</strong>. I have the file in assets folder. How can I read it using typescript? </p>

<p>Thanks in advance :)</p>

<p>I tried passing file path as <code>"e"</code> but the error i am getting is on <code>files[0]</code>. If I remove <code>files[0]</code> error I am getting is <code>parameter 1</code> is not of type <code>'Blob'</code>.  </p>

<pre><code>private readSingleFile(e) {
    var fileName = e.files[0];
    console.log(fileName);
    if (!fileName) {
      return;
    }
    var reader = new FileReader();
    reader.onload = file =&gt; {
      var contents: any = file.target;
      this.text = contents.result;
    };
    reader.readAsText(fileName);
    console.log(reader.readAsText(fileName))
}
</code></pre>