title: Updating table after form submit in AngularJS
body: <p>I have implemented a basic form in angularJS that takes two input values from a user, submits it to a PHP which returns a JSON. I want to insert the values of the JSON in a table. </p>
  
  <p>I have tried using ng-repeat, but it seems that the control never reaches back to the original form. </p>
  
  <p>Is it possible to display the results in a table in an HTML page ?</p>
  
  <p>HTML Page</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
      &lt;title&gt; step 4&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body ng-app="myApp"&gt;
  
          &lt;form name="saveTemplateData" action="#" ng-controller="FormCtrl" &gt;
  
              First name:    &lt;br/&gt;&lt;input type="text" ng-model="form.firstname"&gt;    &lt;br/&gt;&lt;br/&gt;
              &lt;input type="text" ng-model="form.firstname1"&gt;
              &lt;input type="submit" id="submit" value="Submit" ng-click="submitForm()"/&gt;
  
          &lt;/form&gt;
  &lt;ul&gt;
          &lt;li ng-repeat="friend in friends"&gt;
              {{friend.AC_NO}}, {{friend.house_no_en}}
          &lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;script src="angular.min.js"&gt;&lt;/script&gt;  
      &lt;script src = "step4.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Javascript(step4.js)</p>
  
  <pre><code>var app = angular.module('myApp', []);
  app.controller('FormCtrl', function ($scope, $http) {
  
      $scope.formData = {
          firstname: "default",
          firstname1: "default"
      };
  
      $scope.save = function() {
          formData = $scope.form;
      };
  
      $scope.submitForm = function() {
          console.log("posting data....");
          $scope.formData = $scope.form;
  
          $http({method:'GET', url:'http://127.0.0.1/testjson.php', params:{firstname:$scope.formData.firstname, firstname1:$scope.formData.firstname1}}).success(function(data){
              //var pretty;
              $scope.friends = data.response.docs;
  
              var str = JSON.stringify(data, undefined, 2);
              //document.write(str);
  
          }).error(function(data, status, headers, config) {
  
              alert(status);
              });
      };
  });
  </code></pre>