如何打印由火力地堡服务作为数组返回的对象(控制台) [英] How to print object returned by Firebase service as array (to the console)
问题描述
我采用了棱角分明+火力地堡堆栈。
I am using Angular + Firebase stack.
我想转换由火力地堡返回的对象:
I would like to convert object returned by Firebase:
到阵列,因此可以在这样的控制台被打印
into the array so it can be printed in the console like this:
[ {object}, {object}, {object}, {object}, {Object} ];
我知道如何使用模板orderByPriority滤镜,但我不知道如何使用它的内部控制器?
I know how to use "orderByPriority" filter in template but I don't know how to use it inside controller?
推荐答案
如果要打印返回的对象数组到控制台,您需要申请 orderByPriority
过滤器(因为你已经发现了),并使用 $ watchCollection
来监视更改(如数据返回异步
)
If you want to print an array of returned objects to the console, you need to apply orderByPriority
filter (as you already found out) and use $watchCollection
to watch for changes (as data are returned asynchronously
):
$scope.$watchCollection('messages', function() {
console.log(orderByPriorityFilter($scope.messages));
});
您可以看看这个 Plunker 工作方案。
You can check out the working solution in this Plunker.
这篇关于如何打印由火力地堡服务作为数组返回的对象(控制台)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!