[英]How can I pass parameters to an helper?
I want to pass some parameters from my HTML to my meteor helper. 我想将一些参数从HTML传递给流星助手。
Can I do something like this? 我可以做这样的事情吗? ->
- >
{{myHelper "customText"}}
or 要么
{{myHelper context="customText"}}
If so, how do I get back the string "customText"? 如果是这样,如何获取字符串“ customText”? Is it something like this?
是这样吗 ->
- >
"myHelper": function(context){
return this.dataset[context]?"success":"danger"
},
thanks! 谢谢!
Pass parameters to a help like this: 将参数传递给这样的帮助:
<template name="myTemplate">
...
{{myHelper param}}
...
</template>
Then access it in your .js file: 然后在您的.js文件中访问它:
Template.myTemplate.helpers({
myHelper: function(param) {
// do anything with param
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.