由网友(长了樱桃的丸子)分享简介:我采用了棱角分明+火力地堡堆栈。 I am using Angular + Firebase stack. 我想转换由火力地堡返回的对象:I would like to convert object returned by Firebase:到阵列,因此可以在这样的控制台被打印into the array so...
我采用了棱角分明+火力地堡堆栈。
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.
相关推荐
最新文章