Angularjs resource query() result array as a property

前端 未结 1 847
Happy的楠姐
Happy的楠姐 2020-12-30 06:58

I like the way the query() method returns an array of resources, which can be saved to the server again.
I am trying to use Angular against the Drupal RestW

相关标签:
1条回答
  • 2020-12-30 07:45

    With the latest Angular version (1.1.2 or later), you can configure the resource with a transformResponse:

    var MyResource = $resource(
        '/author.js',
        {},
        {
            'get': {
                method: 'GET',
                transformResponse: function (data) {return angular.fromJson(data).list},
                isArray: true //since your list property is an array
            }
        }
    );
    
    0 讨论(0)
提交回复
热议问题