How do I save data to my express server with Angular?
<p>So I been working on this for a few hours and I am suck. So at first I had a cors issue, and solved it. Then I tried several things. What I want to do is to have <code>$resource</code> without making a custom post method. My api is set up using restful standards. <code>POST /artist</code> accepts json with two properties. name and password.</p>

<p>So I tried a few things, as I been on stackoverflow looking at solutions. Here is what I've tried and they all end up posting no data to my server. The data is being set by ng-model and I can see the data with $scope.artist.</p>

<p>attempt 1</p>

<pre><code>$scope.submit = function () {
    console.log('artist:', $scope.artist);
    ArtistSignup.save($scope.artist).$promise
        .then(function (res) {
            console.log('res:', res);
        })
        .catch(function (error) {
            console.log('error:', error.data.message);
        });
    };
</code></pre>

<p>attempt 2</p>

<pre><code>$scope.submit = function () {
    console.log('artist:', $scope.artist);
    $scope.newArtist = new ArtistSignup();
    $scope.newArtist.data = $scope.artist;
    $scope.newArtist.$save($scope.artist)
        .then(function (res) {
            console.log('res:', res);
        })
        .catch(function (error) {
            console.log('error:', error.data.message);
        });
    };
</code></pre>

<p>attempt 3</p>

<pre><code>$scope.artist = new ArtistSignup();
$scope.submit = function () {
    console.log('artist:', $scope.artist);
    $scope.artist.$save()
        .then(function (res) {
            console.log('res:', res);
        })
        .catch(function (error) {
            console.log('error:', error.data.message);
        });
    };
</code></pre>

<p>my factory, i've tried with and without <code>{name: '@name')</code></p>

<pre><code>(function(){
    'use strict';
    angular.module('artistSignup')
        .factory('ArtistSignup', function (backendUrl, $resource) {
            return $resource(backendUrl + '/artist/:name', {name: '@name'});
    });
}());
</code></pre>