Angularjs 角流星出版
我使用的是angular meteor和酷酷的publish composite软件包。我有聊天室,在聊天室下面我有相关的联系人。我正在聊天文档中存储联系人ID。我是这样出版的:Angularjs 角流星出版,angularjs,meteor,Angularjs,Meteor,我使用的是angular meteor和酷酷的publish composite软件包。我有聊天室,在聊天室下面我有相关的联系人。我正在聊天文档中存储联系人ID。我是这样出版的: Meteor.publishComposite('chats', function () { if (! this.userId) { return; } return { find: function() { return Chats.find({ userIds: this.userId
Meteor.publishComposite('chats', function () {
if (! this.userId) {
return;
}
return {
find: function() {
return Chats.find({ userIds: this.userId });
},
children: [
{
collectionName: 'relatedContacts',
find: function(chat) {
let contactIds = [];
if (chat.contactIds) {
contactIds = chat.contactIds;
}
return Contacts.find({ _id: { $in: contactIds } });
}
}
]
}
}))
现在,我正试图在视图中显示我的联系人,但它似乎再也不会返回任何内容。这是我的密码:
RelatedContacts = new Mongo.Collection('relatedContacts');
var app = angular.module('MyApp').controller('ACtrl',
function($scope, $stateParams, $meteor) {
$scope.chat = $meteor.object(Chats, $stateParams.chatId);
$scope.contacts = RelatedContacts.find();
我不知道为什么会出现空白。任何帮助都会很好。谢谢。我真的让它工作了。在我尝试访问相关文档之前,没有加载聊天对象。是否在meteor.isServer()中使用代码包装?