title: How can I resolve TypeError: angular.element(...).scope(...).selectFileForUpload is not a function
body: <p>I'm trying to upload a file in asp.net mvc using angularjs. I have the following as my file upload UI.</p>
  
  <pre><code>&lt;form name="f1" class="form-horizontal" ng-submit="SaveFile()" novalidate&gt;
      &lt;div style="color: red"&gt;{{Message}}&lt;/div&gt;
      &lt;div class="col-md-12"&gt;
          &lt;label&gt;Select File:&lt;/label&gt;
          &lt;input type="file" name="file" accept="image/*"
                 onchange="angular.element(this).scope().selectFileForUpload(this.files)"
                 class="form-control input-bordered" required&gt;                      
          &lt;span class="text-danger" ng-show="(f1.file.$dirty || IsFormSubmitted) &amp;&amp; f1.file.$error.required"&gt;Image required!&lt;/span&gt;
          &lt;span class="text-danger"&gt;{{ FileInvalidMessage }}&lt;/span&gt;
      &lt;/div&gt;
      &lt;div class="col-md-12"&gt;
          &lt;label&gt;Description:&lt;/label&gt;
          &lt;input type="text" name="uFileDescription" class="form-control input-bordered {{(IsFormSubmitted?'ng-dirty' + (f1.uFileDescription.$invalid?' ng-invalid' : ''):'')}}" autofocus data-ng-model="FileDescription" /&gt;
      &lt;/div&gt;
      &lt;div class="col-md-12"&gt;
          &lt;button type="submit" class="btn btn--primary"&gt;Upload File&lt;/button&gt;
          &lt;a href="#/FileUpload" class="btn btn--secondary"&gt;Cancel&lt;/a&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The section where the above error is coming from is this:</p>
  
  <pre><code> &lt;input type="file" name="file" accept="image/*" onchange="angular.element(this).scope().selectFileForUpload(this.files)" class="form-control input-bordered" required&gt;
  </code></pre>
  
  <p>A portion of my controller has this function as a scope variable.</p>
  
  <pre><code>      $scope.selectFileForUpload = function (files) {
              $scope.SelectedFileForUpload = file[0];
        }
  </code></pre>
  
  <p>What should I do differently to avoid this error?</p>