title: AngularJS form returns undefined
body: <p>I'm writing a simple login service, I'm just trying to make username and password, send them to php and get simple console.log 'GJ'. Everything works fine until i get response 'Error' from my PHP function. I tryed to console.log data I'm sending and it says undefined. I tryed to stringify with JSON same thing. Can anyone check where i have it wrong</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>       &lt;div class="container login"&gt;
         &lt;div class="column column-4"&gt;
          &lt;form  name="from1" role="form"&gt;
  
          &lt;label for=""&gt;{{user.mail}}&lt;/label&gt; &lt;br&gt;
          &lt;input type="text"  placeholder="username" required ng-   
           model="user.mail"&gt;&lt;br&gt;
          &lt;label for=""&gt;{{user.pass}}&lt;/label&gt; &lt;br&gt;
          &lt;input type="text"  placeholder="password" required ng-
          model="user.pass"&gt;&lt;br&gt;
          &lt;button  name="submit" class="btn btn-default"  ng-click="login()"&gt;   
           Submit&lt;/button&gt;
           &lt;/form&gt;
          &lt;/div&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p><strong>MAIN.JS</strong></p>
  
  <pre><code>    app.factory('loginService',function($http){
      return{
          login:function(user,scope){
              var $promise = $http.post('http://site1.local/user.php', user);   
         //send data to user.php
              $promise.then(function(msg){
                  if(msg.data=='success') console.log("GJ");
                  else console.log("DARN IT");
              });
          }
       }
  
  });
  
  app.controller('LoginCtrl', function( $scope, loginService ) {
     $scope.login=function(user){
        console.log(user);
          loginService.login(user,$scope); //call login service
      };
  });
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php 
  
      $data = file_get_contents("php://input");
      $user = json_decode($data);
      if($user-&gt;mail=='admin' &amp;&amp; $user-&gt;pass=='1234') 
          print 'success';
      else 
          print 'error';
  
  ?&gt;
  </code></pre>