Ng-repeat 不加载数组中的每个项目
Ng-repeat not loading each item in the array
所以我试图重复一些名为更新的帖子。
<div ng-repeat"update in updates.updates">
{{update.content}}
</div>
如果我执行 {{updates}} 我会得到这个(注意它是更新中的一个数组。所以我试图重复 updates.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;
});
}
这是 express 控制器:
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: []
});
}
}
)});
您的 ng-repeat 缺失等于括号:
<div ng-repeat="update in updates.updates">
{{update.content}}
</div>
我漏掉了一个等号。 ng-repeat="
所以我试图重复一些名为更新的帖子。
<div ng-repeat"update in updates.updates">
{{update.content}}
</div>
如果我执行 {{updates}} 我会得到这个(注意它是更新中的一个数组。所以我试图重复 updates.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;
});
}
这是 express 控制器:
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: []
});
}
}
)});
您的 ng-repeat 缺失等于括号:
<div ng-repeat="update in updates.updates">
{{update.content}}
</div>
我漏掉了一个等号。 ng-repeat="