Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $resource返回具有数字属性的对象_Javascript_Angularjs - Fatal编程技术网

Javascript $resource返回具有数字属性的对象

Javascript $resource返回具有数字属性的对象,javascript,angularjs,Javascript,Angularjs,我试图从CouchDB\u更新读取返回值,该更新返回一个字符串。我通过AngularJS$资源调用它,如下所示: var cb = function(rtn){console.log(rtn);}; var foo = $resource('/myDb/_design/myDesignDoc/_update/thingie/:arg', {}, { update: {method: 'PUT'}}); foo.update({arg: "blah"}, null, cb); JSON.stri

我试图从CouchDB\u更新读取返回值,该更新返回一个字符串。我通过AngularJS$资源调用它,如下所示:

var cb = function(rtn){console.log(rtn);};
var foo = $resource('/myDb/_design/myDesignDoc/_update/thingie/:arg', {}, { update: {method: 'PUT'}});
foo.update({arg: "blah"}, null, cb);
JSON.stringify({rtn_value: "the actual return value"})
这会将以下内容打印到控制台:

Object { 0: "4", 1: "d", 2: "a", 3: "7", 4: "3", 5: "1", 6: "1", 7: "4", 8: "-", 9: "8", 51 more… }
带有数字索引的属性是我想要的输出,但是如何将它们转换回字符串呢

我尝试了rtn.join,但它抱怨找不到rtn.join。我怀疑这是显而易见的,但我现在陷入困境…

未回答的问题似乎与我的问题非常相似。一个是自我回答,建议退回字典而不是字符串。简单地返回字典对我不起作用,但返回包含字典的JSON字符串却起作用,如下所示:

var cb = function(rtn){console.log(rtn);};
var foo = $resource('/myDb/_design/myDesignDoc/_update/thingie/:arg', {}, { update: {method: 'PUT'}});
foo.update({arg: "blah"}, null, cb);
JSON.stringify({rtn_value: "the actual return value"})
抱怨。这真的应该添加到AngularJS文档中。。。也许我会这样做或者更好,读过这篇文章的人应该这样做