【发布时间】:2015-10-24 12:30:06
【问题描述】:
我需要在我的流星应用程序的waitOn 函数中从RouteController 访问会话变量,我在模板的onCreated 块上设置了一个会话变量:
Template.practicalQuestionForm.onCreated ->
Session.set 'domId', Random.id()
然后我需要从我的控制器访问那个会话变量Session.get 'domId',看看waitOn:
@testsAddQuestionController = testsQuestionsController.extend
template: ->
qType = Router.current().params.type
if qType == 'practical'
'practicalQuestionForm'
else if qType == 'mcq'
'mcqQuestionForm'
waitOn: ->
console.log Session.get 'domId'
Meteor.subscribe 'currentSessionUploads', Session.get 'domId'
data: ->
questions: TestQuestions.find()
test: Tests.findOne slug: this.params.slug
previous: TestQuestions.find({}, sort: createdAt: 1, limit: 1).fetch().pop()
但是我只收到undefined 有人可以告诉我这是否可能吗?如果不是,您可以向我建议其他替代方案吗?
提前致谢。
【问题讨论】:
标签: session meteor coffeescript iron-router