我正在尝试订阅与登录用户不同的用户的 profdle 信息,但我遇到了如下所述的问题,我正在使用 angular-material,我的代码如下所示:
//publish user info upon following user
Meteor.publish("getUserInfo", function (userId) {
return (Meteor.users.find({_id: userId}, {fields: {profile: 1}}));
});
//subscribe
$scope.$meteorSubscribe("getUserInfo", askLikeController.$root.askLike[0].userId).then(function (subscriptionHandle) {
//Second element in the userProfile array will have the profile of required user
askLikeController.$root.usersProfile = $meteor.collection(Meteor.users, false);
});
问题: 1. 在变量 askLikeController.$root.usersProfile 中,我得到了已登录的用户和具有 userId 的所需用户信息,我期待只有所需用户 ID 的用户信息,这是为什么呢?2.订阅“getUserInfo”不是反应性的,甚至在处理几块代码之后订阅也会丢失,然后在 askLikeController.$root.usersProfile 我只剩下登录用户的用户配置文件,我的猜测是我的订阅正在被用户的内置 Meteor 订阅所取代。
我该如何解决这些问题?
问候,赤丹