我在mongoDB中有2个集合:
消息:
{
"_id" : ObjectId("542e65368a1cec1227ae2bac"),
"message" : "hello"
}
类:
{
"_id" : ObjectId("542e65368a1cec1227ae2bac"),
"result" : {
"full" : "voyage",
"others" : "voyage"
}
}
我可以显示收藏消息:
中的ID "542e65368a1cec1227ae2bac, hello":
使用:
{{image._id}},{{image.message}}
来自我的JSON:
{ "images" :
[
{
"_id" : "542e65368a1cec1227ae2bac",
"message" : "hello"
}
]
}
但我想展示" voyage" 。
感谢您的帮助
答案 0 :(得分:1)
var app = angular.module('app', []);
app.controller('fCtrl', function($scope) {
$scope.messages = {
"images": [{
"_id": "542e65368a1cec1227ae2bac",
"message": "hello"
}]
}
$scope.categories = [{
"_id": "542e65368a1cec1227ae2bac",
"result": {
"full": "voyage",
"others": "voyage"
}
}]
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<div ng-controller="fCtrl">
<div ng-repeat="message in messages.images">
<p>{{message._id}} - {{message.message}}
<p ng-repeat="cat in categories | filter: {'_id':message._id}">{{cat.result.others}}</p>
</div>
</div>
</div>
&#13;