title: Posting Input value as param to web service API in Angular
body: <p>I have started learning Angular and I'm stuck on something that should be trivial. I'm from a Rails background and created a very simple Rails web-service that manages a MailingList. Currently 2x API endpoints exist in my web-service:</p>
  
  <pre><code>/api/v1/mailing_lists [GET]
  /api/v1/mailing_lists [POST]
  </code></pre>
  
  <p>The POST endpoint requires a valid email as a PARAM in the API call. And this is where I'm stuck. How do I pass this param to my API in Angular? I've tried using solutions from around the web but I'm just not getting it right. Here's what I have thus far:</p>
  
  <p>In my services.js:</p>
  
  <pre><code>angular.module('webFrontendApp.services', []).factory('MailingList', function($resource) {
      var data = $resource(
        'http://localhost:3000/api/v1/mailing_lists.json',
        {},
        {
          // 'get': { method:'GET', cache: false},
          'query': { method:'GET', cache: false, isArray:true },
          'save': {method: 'POST', cache: false }
        });
      return data;
  });
  </code></pre>
  
  <p>In app.js</p>
  
  <pre><code>....
  .when('/list/new', {
          templateUrl: 'views/list-new.html',
              controller: 'MailingListCtrl'
        })
  
  ....
  </code></pre>
  
  <p>Controller as mailinglist.js</p>
  
  <p>angular.module('webFrontendApp.controllers', [])</p>
  
  <pre><code>.controller('MailingListCtrl', function($scope, MailingList) {
      // Get all posts
      $scope.mailing_lists = MailingList.query();
  
      // Our form data for creating a new post with ng-model
      $scope.memberData = {};
      $scope.newMember = function() {
        var member = new MailingList($scope.memberData);
        member.$save();
      };
  });
  </code></pre>
  
  <p>The form looks like this:</p>
  
  <pre><code>&lt;form role="form" ng-submit="newMember()"&gt;
    &lt;div class="row"&gt;
      &lt;div class="input-group"&gt;
        &lt;input type="text" ng-model="memberData.email" placeholder="New mailing list member" class="form-control"&gt;
        &lt;span class="input-group-btn"&gt;
          &lt;input type="submit" class="btn btn-primary" value="Add"&gt;
        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I submit the form, nothing seems to happen, but I am receiving a 405 error response from my web service. After looking into my Web Service logs, I can see that a POST request was received but no params were passed and thus it was rejected.</p>
  
  <p>Any help will be greatly appreciated!</p>
  
  <p>PS. I have made sure to Enable CORS on my Rails app.</p>