title: AngularJS PUT works, POST returns undefined scope values
body: <p>With the code I can update the users that are listed, but adding new Users doesn't work. The scope of the input for new items is undefined always. It does submit something, but without the values I filled in, in the form. The <code>console.log($scope.newMail)</code> return <code>undefined</code> for example.</p>
  
  <pre><code>&lt;script&gt;
  function UsersController($scope, $http, $location) {
      $http.get('/users').success(function(users) {
          $scope.users = users;
      });
  
      $scope.addUser = function(user) {
          var user = {
              name:   $scope.newName, // with hardcoding values here it does work
              email:      $scope.newMail // but with newValues, both stay null always
          };
          console.log(user); // returns undefined values
          $http.post('/users', user);
      }
  
      $scope.updateUser = function(user) {
          $http.put('/users/'+user.id, user);
      }
  }
  &lt;/script&gt;
  
  
  &lt;section ng-controller="UsersController"&gt;
  
      &lt;!-- ng-repeat --&gt;
      &lt;div ng-repeat="user in users"&gt;
          &lt;form ng-submit="updateUser(user)"&gt;
  
              &lt;input type="hidden" ng-model="user.id" value="{{ user.id }}"/&gt;
              &lt;input type="text" value="{{ user.name }}" ng-model="user.name" /&gt;
              &lt;input type="email" value="{{ user.email }}" ng-model="user.email" /&gt;
  
              &lt;button type="submit" /&gt;
          &lt;/form&gt;
  
  
          &lt;section ng-show="toggleForm"&gt;
  
              &lt;form ng-submit="addUser(user)"&gt;
                  &lt;input type="text" ng-model="newName" required /&gt;
                  &lt;input type="email" ng-model="newMail" required /&gt;
  
                  &lt;button type="submit" ng-click="toggleForm = !toggleForm"/&gt;
              &lt;/form&gt;
  
          &lt;/section&gt;
  
          &lt;a ng-click="toggleForm = !toggleForm"&gt;&lt;p&gt;New user&lt;/p&gt;&lt;/a&gt;
  
      &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>Can't figure out what is wrong. What am I missing?</p>
  
  <p>I implemented solution #3:</p>
  
  <pre><code>TypeError: Cannot set property 'mail' of undefined
      at setter (//urlassets/app.js:3:26728)
      at extend.assign (//urlassets/app.js:5:29229)
      at $setViewValue (//urlassets/app.js:6:5077)
      at //urlassets/app.js:4:31686
      at Scope.$eval (//urlassets/app.js:4:9722)
      at Scope.$apply (//urlassets/app.js:4:10068)
      at Scope.$delegate.__proto__.$apply (&lt;anonymous&gt;:855:30)
      at HTMLInputElement.listener (//urlassets/app.js:4:31663)
      at //urlassets/app.js:1:29072
      at forEach (//urlassets/app.js:1:8278)
  </code></pre>
  
  <p>And looks like: <a href="https://www.dropbox.com/s/3nhkhcsz3g6d6iy/test.mov" rel="nofollow">https://www.dropbox.com/s/3nhkhcsz3g6d6iy/test.mov</a></p>