title: How to write data to the json file using $http post method in angularjs?
body: <p>I have a json file containing an array of objects, I would like to know the $http post method to add another object to this json (containing the array of objects). Assume all 3 files in the same folder. This has to be done in angularjs. Please help &amp; for any additional details, just ask. Cheers!</p>
  
  <p>--contact_details.json---</p>
  
  <pre><code>[{
    "name": "Darshil Patira",
    "number": "9829038347",
    "image": "images/dawn_scenic.jpg",
    "email": "darshilpatira@gmail.com"
  }, {
    "name": "Sujith V",
    "number": "9756423129",
    "image": "images/blue_ocean.jpg",
    "email": "sujithv@gmail.com"
  }]    
  </code></pre>
  
  <p>---addcontact.html---</p>
  
  <pre><code>&lt;div class="form-style"&gt;
      &lt;div class="form-style-heading"&gt;
          Provide your information
      &lt;/div&gt;
      &lt;form name="reviewForm" action="" ng-submit="addcontact()" ng-controller="addContactController"&gt;
          &lt;label for="field1"&gt;
              &lt;span&gt;Name&lt;span class="require"&gt;*&lt;/span&gt;
              &lt;/span&gt;
              &lt;input type="text" class="input-field" name="field1" ng-model="name" required /&gt;
          &lt;/label&gt;
          &lt;label for="field2"&gt;
              &lt;span&gt;Email&lt;span class="require"&gt;*&lt;/span&gt;
              &lt;/span&gt;
              &lt;input type="text" class="input-field" name="field2" ng-model="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required /&gt;
          &lt;/label&gt;
          &lt;label for="field3"&gt;
              &lt;span&gt;Telephone&lt;span class="require"&gt;*&lt;/span&gt;
              &lt;/span&gt;
              &lt;input type="text" class="tel-number-field" name="field3" ng-model="number" pattern=".{5,10}" required /&gt;
          &lt;/label&gt;
          &lt;input type="file" name="pic" accept="image/jpg"&gt;
          &lt;label&gt;
              &lt;span&gt;&amp;nbsp;&lt;/span&gt;
              &lt;input type="submit" value="Submit" /&gt;
          &lt;/label&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>---app.js(Controller)---</p>
  
  <pre><code>var app = angular.module("mainApp", ['ngRoute']);
  
  app.controller('addContactController',function($scope,$http){
      var dataobj = { 'name':$scope.name, 'email': $scope.email, 'number':$scope.number };
      $http.post('contacts_details.json',dataobj);
  });
  </code></pre>