在我的应用程序中,我希望人们能够访问公共用户档案。显然,我不想一次发布所有用户的数据,而是只在访问时发布。有了Iron Router,我有了
waitOn: function() {
Meteor.subscribe('getPublicProfileData', this.params._id);
}
在公共配置文件的路由中。AngularJS的ui路由器的等价物是什么?
我做了整个"在为SO制定问题时回答你自己的问题"的事情,所以我想我会发布我的解决方案:
.state('profile', {
url: '/profile/:userId',
templateUrl: 'client/templates/profile.html',
controller: 'ProfileCtrl as profile',
resolve: {
getProfile($stateParams) {
return Meteor.subscribe('getPublicProfileData', $stateParams.userId);
}
}
});
请确保在解析函数中包含$stateParams,以便在Meteor订阅中获取id。