【发布时间】:2014-07-04 12:17:40
【问题描述】:
我的路由器里有这个:
Router.configure
layoutTemplate: 'layout'
loadingTemplate: 'loading'
Router.map () ->
@route 'home',
path: '/'
waitOn: ->
Meteor.subscribe('users')
Meteor.subscribe('instruments')
Meteor.subscribe('instrumentList')
data: ->
Meteor.users.find().fetch()
@route 'edit_form',
path: 'edit_profile'
waitOn: ->
Meteor.subscribe('user', Meteor.userId)
Meteor.subscribe('users')
Meteor.subscribe('instruments')
Meteor.subscribe('instrumentList')
data: ->
Meteor.user()
Router.onBeforeAction("loading")
home 是一个谷歌地图,显示系统中所有用户丢弃的图钉。
home 需要订阅整个users 集合。
edit_form 是当前登录用户的表单。
edit_form 只需订阅current_user 文档。
- 当我第一次访问
home时,地图会显示每个用户的所有 Pin 图。 - 然后我导航到
edit_form,它会显示当前用户的所有信息。 - 然后我直接导航回地图,它只显示当前用户的图钉。
这里发生了什么?为什么步骤 3 中的 home 路由现在只显示当前用户的 pin,即使我特别告诉它 waitOn 订阅整个 users 集合并使用来自 Meteor.users.find().fetch() 的数据,它应该获取集合中的每个用户?
【问题讨论】:
标签: meteor iron-router