Javascript 使用ngResource AngularJS将发布的表单数据放入自定义api端点

Javascript 使用ngResource AngularJS将发布的表单数据放入自定义api端点,javascript,angularjs,json,ngresource,Javascript,Angularjs,Json,Ngresource,我的任务是创建一个新的自定义api端点,我想在现有俱乐部资源中称之为“associate”,我已经为资源创建了一个名为“associate”的新功能,该功能将从使用输入标记指令创建的表单中“发布”所选数据,并将其放入一个新的JSON Blob中,附加到父blob的,例如: 以下是资源: angular.module('AppResource') .factory('Club', ['$resource', function ($resource) { 'use strict';

我的任务是创建一个新的自定义api端点,我想在现有俱乐部资源中称之为“associate”,我已经为资源创建了一个名为“associate”的新功能,该功能将从使用输入标记指令创建的表单中“发布”所选数据,并将其放入一个新的JSON Blob中,附加到父blob的,例如:

以下是资源:

angular.module('AppResource')
.factory('Club', ['$resource', function ($resource) {

    'use strict';

    return $resource('/api/v1/users/:user_id/clubs/:club_id',
        {
            club_id: '@id',
            user_id: '@user_id'
        }, {
            update: {
                method: 'PUT'
            },
            delete: {
                method: 'DELETE'
            },
            associate: {
                method: 'POST',
                url: '/api/v1/users/:user_id/clubs/:club_id/associate'
            }
        });
}]);
我似乎无法使用控制器中的以下javascript获取表单以将此数据发送到此新自定义端点,以下代码是导致控制台中出现错误的原因:

//additional programming above relates to other aspects of the view//

},function (assign) {
                Club.$associate({user_id: assign.user_id, club_id: assign.id}, {
                    club_account_id: assign.club_account.name
                });

//club_account_id relates to another injected resource which determines
//the details within each club account. I need the property
//club_account.name to be sent from the form when captured 
//by the input tag directive
错误:angular.min.js:114类型错误:无法读取未定义的属性“club_account”

HTML:

视图使用标记输入指令

<div class="col-md-7">
                <tags-input class="form-control" ng-model="form.club_accounts" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Start Typing an Club Name">
                    <auto-complete source="club_accounts"></auto-complete>
                </tags-input>
</div>

我尝试了很多不同的方法,但仍然得到了TypeError引用,其中无法读取未定义的属性id


有什么想法吗

请显示所有相关的代码上下文,并提供错误的详细信息,说明在该代码中抛出的位置。您的JSON无效。Hi@charlietfl我已为该问题添加了更多详细信息。我希望这能让我更容易明白我想做什么。
<div class="col-md-7">
                <tags-input class="form-control" ng-model="form.club_accounts" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Start Typing an Club Name">
                    <auto-complete source="club_accounts"></auto-complete>
                </tags-input>
</div>