如何从角度资源承诺中读取数据 [英] How to read data out of angular Resource promise
本文介绍了如何从角度资源承诺中读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在从返回的角度承诺中读取数据时遇到问题.
I am having problem reading my data out of angular promise returned.
以前我做过
var data = category.get({id:userid});
然后我意识到数据返回了一个未解决的承诺.然后将其更改为
Then i realised data returned an unresolved promised . Then changed it to
category.get({id:userid}, function(result){
console.log('the result are', result);
});
当我打印结果时,我注意到它现在已经解决了,并且我的数据位于Resource:0之内,如下所示.
When i print my result, i noticed its now a resolved promise with my data inside Resource : 0 like below.
请问我如何访问下面的资源?它似乎不允许访问.任何帮助将不胜感激
Please how to i access the Resource below ? It does not seem to allow access. Any help would be appreciated
推荐答案
如果您想实际使用 promise
,则可以执行以下操作:
If you want to actually use the promise
you can do:
category.get(...)
.$promise.then(function(result)) {
console.log(result);
});
否则,您没有使用诺言.
Otherwise, you're not using a promise.
这篇关于如何从角度资源承诺中读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文