title: AngularJS: How to call function on onsubmit inside the controller as ng-submit
body: <p>I am developing mobile app in angularJS, ionic framework and cordova. I am having a scenario where form data i am submitting to server and when server respond me with the status as 200 i am navigating user to the confirmation page. My code is:</p>
  
  <pre><code>&lt;ion-view title="Fill the Form" ng-controller="formSubmit"&gt;
  &lt;ion-content class="padding-vertical" ng-repeat="htmlValue in HTML"&gt;
      &lt;form name="fieldForm" id="{{htmlValue.Id}}" method="post" onsubmit="submitFormData($(this).serialize(), $(this).attr('id'))"&gt;
          &lt;div class="bootstrap" ng-bind-html="htmlValue.Html | unsafe"&gt;
  
          &lt;/div&gt;
          &lt;div class="padding"&gt;
              &lt;button  class="button button-block button-calm"&gt;
                  Submit
              &lt;/button&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  
      &lt;div class="clearfix"&gt;&lt;/div&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p>
  The function i have written below the index.html page before the body ends.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function submitFormData(serializedData,value){
          var data = serializedData;
          $.ajax({
              url: base_url+"put/putFormFilledRawData.php?id="+value,
              type: "POST",
              data: data,
              success: function(tableData){
                  alert('success');
              }});
          return false;
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>Thing is when response arrives as 200 i have to navigate through $state.go() function and for that this function needs to be accessed inside the controller. For that i tried ng-submit at the place of onsubmit but is always shows me error: <code>submitFormData</code> is not a function. How to make it work inside controller from front view forms submit call?</p>