Ng-repeat不加载数组中的每个项目

时间:2015-01-07 18:31:41

标签: angularjs mongodb

所以我试图重复一些名为更新的帖子。

<div ng-repeat"update in updates.updates">   
{{update.content}}
</div>

如果我{{updates}}我得到了这个(注意它是更新中的数组。所以我试图重复更新。更新)。

{"updates":
[{"_id":"54ad53cc63b627c111fec6ac","content":"Post","author":"5485ef86028950a880f7f878","date":"2015-01-07T15:42:04.768Z"},
{"_id":"54ad547840f3d5db11c6da63","content":"sad","author":"5485ef86028950a880f7f878","date":"2015-01-07T15:44:56.395Z"},
{"_id":"54ad54b987cd37e611761d4e","content":"Soadfasdf","author":"5485ef86028950a880f7f878","date":"2015-01-07T15:46:01.066Z"},
{"_id":"54ad55345326d0f911427ea0","content":"asdf","author":"5485ef86028950a880f7f878","date":"2015-01-07T15:48:04.717Z"},
{"_id":"54ad6240df3ebc9813364d13","content":"asdf","author":"5485ef86028950a880f7f878","date":"2015-01-07T16:43:44.623Z"}]}

所以阵列就在那里......它正在使用{{updates}}但不是ng-repeat。有关如何解决此问题的任何建议吗?

控制器代码:

    function getUpdates() {
        Updates.getUpdates().then(function (data) {
            $scope.updates = data;

        });
    }

这是快递控制器:

    db.collection('updates', function (err, collection) {
        collection.find({
            author: req.user._id
        }).toArray(function (err, docs) {
            if (err) {
                console.log('updates.get.error', err);
                throw err;
            }
            // they have messages
            if (docs) {
                console.log(docs);
                res.send({
                    updates: docs
                });
            } else {
                console.log('Didnt find updates');
                res.send({
                    updates: []
                });
            }

        }

    )});

2 个答案:

答案 0 :(得分:3)

您的ng-repeat缺失等于括号:

<div ng-repeat="update in updates.updates">   
{{update.content}}
</div>

答案 1 :(得分:1)

我错过了一个等号。 NG-重复=“