0

I'm passing variables to template:

{{> myTemplate myVariable}}

Inside myTemplate I access it with:

<template name="myTemplate">
  {{this}}
</template>

Where this will be myVariable

How can I access myVariable from the code - onCreated, onRendered, helpers of myTemplate.

Example:

Template.myTemplate.onCreated(function(){
  // How access myVariable here?
});

or

Template.myTemplate.onRendered(function(){
  // How access myVariable here?
});

1 Answer 1

1

In the onCreated and onRendered callbacks, this.data points to the passed data:

Template.myTemplate.onCreated(function(){
  console.log(this.data);
});

Template.myTemplate.onRendered(function(){
  console.log(this.data);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.