title: preview selected image in angular
body: <p>I need to preview selected file in angular 6. So I used the following code for that. But there are a few errors. Here's my implementation:</p>
  
  <pre><code>export class AppComponent {
    title = 'imgpreview';
  
    url = '';
    onSelectFile(event) {
      if (event.target.files &amp;&amp; event.target.files[0]) {
        var reader = new FileReader();
  
        reader.readAsDataURL(event.target.files[0]); // read file as data url
  
        reader.onload = (event) =&gt; { // called once readAsDataURL is completed
          this.url = event.target.result;
        }
      }
    }
  }
  </code></pre>
  
  <p>The error I'm getting:</p>
  
  <blockquote>
    <p>error is ERROR in src/app/app.component.ts(19,33): error TS2339: Property 'result' does not exist on type 'EventTarget'.</p>
  </blockquote>
  
  <p>how do I solve this?</p>