I can’t use Template.instance()
in sub template helper
<template name="main">
{{> subTemplate}}
</template>
<template name="subTemplate">
{{hello}}
</template>
-----------------
// Sub Template
subTemplate.onCreated(() => {
this.hello = new ReactiveVar('Rabbit')
console.log('onCreated', this.hello.get()) // Work
})
subTemplate.onRendered(() => {
console.log('onRendered', this.hello.get()) // Work
})
subTemplate.helpers({
hello() {
return Template.instance().hello.get() // Don't work
},
})
Get the error
template helper: TypeError: Cannot read property 'get' of undefined
Please help me