title: Unable to read content of text file using angularjs
body: <h1>Error : Cannot read property 'addEventListener' of null</h1>
  <p>I have to upload a file from local system ,read content of it and pass it to variable. As per business requirement when user click on a button a modal opens and in that modal I have to upload file and read content.</p>
  <p><strong>button which will open modal</strong></p>
  <pre><code>&lt;div ng-controller=&quot;CreateTestController as t_ctrl&quot;&gt; 
       &lt;button class=&quot;btn btn-primary btn-md&quot; ng-
        click=&quot;t_ctrl.importSteps()&quot;&gt;Import Steps&lt;/button&gt;
  &lt;/div&gt;
  
  myApp.controller('CreateTestController', function (TestScriptApi, $scope, $modal, $rootScope) {
  var t_ctrl = this;
  t_ctrl.formData = {
      test1: '',
      test2: ''
  }
  /* some funationality */
  
  // import steps added 
  
  vm.importSteps = function () {
      $modal.open({
          size: 'md',
          templateUrl: 'js/some_location/import-step.html?',
          controller: 'ImportStepController as importStepController',
          resolve: {
              t_ctrl: function () {
                  return t_ctrl;
              }
          }
      });
  };
  });
  </code></pre>
  <p><strong>import-step.html</strong></p>
  <pre><code>&lt;div &gt;
      &lt;input type=&quot;file&quot; name=&quot;file&quot; id=&quot;importFile&quot; &gt;
      &lt;button type=&quot;button&quot; ng-click=&quot;readFilex()&quot;&gt;Some Button&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  <hr />
  <p><strong>import-step.js</strong></p>
  <pre><code>myApp.controller('ImportTestStepController', function ($scope, $modalInstance, t_ctrl) {
      var vm = this;
  
      vm.sequenceNo = '';
      vm.command = '';
      vm.method = '';
  
  
      var x = document.getElementById('importFile');
      x.onchange = function () {
          var file = this.files[0];
          alert(&quot;working&quot;);
          var reader = new FileReader();
          reader.onload = function (evnt) {
              // Entire file
              console.log(this.result);
  
              // By lines
              var lines = this.result.split('\n');
              for (var line = 0; line &lt; lines.length; line++) {
                  // By tabs
                  var tabs = lines[line].split('\t');
                  for (var tab = 0; tab &lt; tabs.length; tab++) {
                      alert(tabs[tab]);
                  }
              }
          };
  
          reader.readAsText(file);
      };
  });
  </code></pre>