我从Parse数据库中获取一些对象并在我的模板中显示它们:
JS:
angular.module('yoApp')
.controller('downloadsCtrl', function($q, $scope, $rootScope, $http, appService, serviceUpload, fileUpload) {
$scope.downloads = []
var Download = Parse.Object.extend('Download')
var query = new Parse.Query(Download)
query.find({
success: function(results) {
_.each(results, function(result) {
$scope.downloads.push(result.toJSON())
console.log($scope.downloads)
$scope.$apply
})
},
error: function(error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and message.
}
})
})
HTML:
<pre>{{downloads | json}}</pre>
console.log($scope.downloads)
输出对象:[Object, Object]
。
但他们没有在<pre></pre>
这是为什么?以及如何实现我想要的目标?
答案 0 :(得分:1)
您忘记执行$apply
功能。尝试将其更改为$scope.$apply();