title: AngularJS changing a form action on the submit event
body: <p>I have a form where the url action come from an API call.</p>
  
  <p>So, in the submit event of the form I need to call an API that receive the URL then I need set the action of the form and trigger the POST.</p>
  
  <p>But, all the steps must run only when the user click on the submit button.</p>
  
  <p>I tried:</p>
  
  <pre><code>&lt;form name="myForm" ng-submit="form.submit()" method="post" enctype="multipart/form-data" &gt;
      &lt;input type="file" name="file" id="file"&gt;
      &lt;input type="submit" value="Upload Image" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>angular.module('formCtrl', ['formService', 'authService'])
  
  .controller('formController', function($scope, $http, Form, AuthToken) {
  
      var vm = this;
  
      vm.submit = function() {
  
          Form.get().success(function(data) 
          {
              if (data.url) 
              {
  
                  document.myForm.action = data.url;
                  document.myForm.submit();
  
              }
          });
      }
  
  });
  </code></pre>
  
  <p>But didn't work. Actually, I tried a lot of thing without success.</p>
  
  <p>And I'm not using jquery in my project.</p>
  
  <p>Can some one give me some help in how to do it ?</p>