Meteor.js 1.0-包含Iron路由器和模板助手的数据上下文
我正在使用Iron路由器将数据传递到我的模板:Meteor.js 1.0-包含Iron路由器和模板助手的数据上下文,meteor,coffeescript,Meteor,Coffeescript,我正在使用Iron路由器将数据传递到我的模板: @route 'singleProperty', path: '/properties/:_id' data: -> Properties.findOne(@params._id) controller: "SinglePropertyController" 在我的控制器中,我的模板正在等待发布必要的集合: waitOn: -> [ Meteor.subscribe "properties" ]
@route 'singleProperty',
path: '/properties/:_id'
data: ->
Properties.findOne(@params._id)
controller: "SinglePropertyController"
在我的控制器中,我的模板正在等待发布必要的集合:
waitOn: ->
[
Meteor.subscribe "properties"
]
我遇到的问题是,当我试图从助手中访问@数据时,它返回为未定义的:
Template.singleProperty.helpers
currentProperty: ->
console.log @data
也就是说,当我在模板.rendered
中运行相同的控制台.log
时,我会得到预期的结果(数据
对象):
我需要更改什么才能访问模板.helper中的数据
在模板助手方法中尝试以下操作:
模板.currentData()
Template.instance()是本课程中阅读的关键内容
希望这有帮助。Template.currentData()成功了。要是我在3小时前读到这篇文章就好了!很高兴看到它的帮助…有时我们只是看不到树木的树木。。。
Template.singleProperty.rendered = ->
console.log @data