title: Sending form data to server in AngularJS
body: <p>I have my html like this:</p>
  
  <pre><code>&lt;form ng-submit="addNews(news)" ng-controller='FormController'&gt;
  
  &lt;input type="text" placeholder="autor" name="autor" ng-model="todos.autor"&gt;
  &lt;input type="submit" value="click"&gt;
  
  {{todos.autor}}
  {{todos}}
  
  &lt;span&gt; &lt;var&gt;result:&lt;/var&gt; &lt;mark&gt;{{result}}&lt;/mark&gt;&lt;/span&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>using the ng-model directive for the input(as you can see "todos.autor")</p>
  
  <p>my controller (FormController) like this:</p>
  
  <pre><code>$scope.addNews = function(news){
  
      $http.post('send_data.php', {'autor': $scope.todos.autor}).
      success(function(data, status) {
          $scope.status = status;
          $scope.data = data;
          $scope.result = data;
      })
  </code></pre>
  
  <p>and finally my php (send_data):</p>
  
  <pre><code>&lt;?php
  $data = json_decode(file_get_contents("php://input"));
  echo $data-&gt;autor;
  
  ?&gt;
  </code></pre>
  
  <p>when the user clicks on submit I call the addNews function from my controller, this function should send the data the user write in the input, then on success the <code>$scope.result</code> will contains the info and finally the result will be mark up in the html (<code>&lt;mark&gt;{{result}}&lt;/mark&gt;</code>) (a simple example). <br><br> </p>
  
  <p>The problem is that no result is shown unless I change my ng-model from <code>todos.autor</code> to simple <code>autor</code> and in the controller change from <code>{'autor': $scope.todos.autor}</code> to <code>{'autor':$scope.autor}</code> (I verified this) I really need to have the <code>todos.autor</code> and not a simple <code>autor</code> <br><br></p>
  
  <p>how do I achive the controlled send the data in this way? thanks</p>