问题
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} ];
I know how to use "orderByPriority" filter in template but I don't know how to use it inside controller?
回答1:
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));
});
You can check out the working solution in this Plunker.
来源:https://stackoverflow.com/questions/22322299/how-to-print-object-returned-by-firebase-service-as-array-to-the-console