title: AngularJS - PUT method not working (404 error)
body: <p>I'm new to AngularJS and I have trouble to update an object via REST. I'm using a PHP/Mysql Backend (Slim Framework).<br>
  I'm able to retrieve (GET), create (POST) a new object but not to edit (PUT) one. Here's the code:</p>
  
  <p>my Form:</p>
  
  <pre><code>&lt;form name="actionForm" novalidate ng-submit="submitAction();"&gt;
    Name: &lt;input type="text" ng-model="action.name" name="name" required&gt;
    &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My service:</p>
  
  <pre><code>var AppServices = angular.module('AppServices', ['ngResource'])
  AppServices.factory('appFactory', function($resource) {
    return $resource('/api/main/actions/:actionid', {}, {
      'update': { method: 'PUT'},
    });
  });
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var app = angular.module('app', ['AppServices'])
  app.config(function($routeProvider) {
    $routeProvider.when('/main/actions', {
      templateUrl: 'partials/main.html',
      controller: 'ActionListCtrl'
    });
    $routeProvider.when('/main/actions/:actionid', {
      templateUrl: 'partials/main.html',
      controller: 'ActionDetailCtrl'
    });
    $routeProvider.otherwise({redirectTo: '/main/actions'});
  });
  </code></pre>
  
  <p>controllers.js:</p>
  
  <pre><code>function ActionDetailCtrl($scope, $routeParams, appFactory, $location) {
    $scope.action = appFactory.get({actionid: $routeParams.actionid});
    $scope.addAction = function() {
      $location.path("/main/actions/new");
    }
    $scope.submitAction = function() {
      // UPDATE CASE
      if ($scope.action.actionid &gt; 0) {
        $scope.action = appFactory.update($scope.action);
        alert('Action "' + $scope.action.title + '" updated');
      } else {
        // CREATE CASE
        $scope.action = appFactory.save($scope.action);
        alert('Action "' + $scope.action.title + '" created');
      }
      $location.path("/main/actions");
    }
  }
  </code></pre>
  
  <p>In Slim, in api/index.php, I've got these routes and functions defined:</p>
  
  <pre><code>$app-&gt;get('/main/actions', 'getActions');
  $app-&gt;get('/main/actions/:actionid',    'getAction');
  $app-&gt;post('/main/actions', 'addAction');
  $app-&gt;put('/main/actions/:actionid', 'updateAction');
  </code></pre>
  
  <p>When I create a new "action", everything is working as expected. But when I try to edit an existing one, I've got this error:</p>
  
  <blockquote>
    <p>PUT <a href="http://project.local/api/main/actions" rel="nofollow">http://project.local/api/main/actions</a> 404 Not Found</p>
  </blockquote>
  
  <p>The action is not updated (although the alert message "Action xxx updated" is displayed)</p>
  
  <p>Is it an issue with my routeProvider setting ? I guess the PUT url misses the id at the end...</p>
  
  <p>I precise that if I try to simulate the PUT request with <a href="https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm" rel="nofollow">POSTMan-Chrome-Extension</a> for example, everything is working well (PUT <a href="http://project.local/api/main/actions/3" rel="nofollow">http://project.local/api/main/actions/3</a> returns the expected data)</p>