在Meteor中生成if语句
我是新来的流星。我开始使用会话使内容在不同的模板之间反应。我还在我的应用程序中使用Ace文本编辑器。它有一些配置设置:在Meteor中生成if语句,meteor,reactive-programming,ace-editor,Meteor,Reactive Programming,Ace Editor,我是新来的流星。我开始使用会话使内容在不同的模板之间反应。我还在我的应用程序中使用Ace文本编辑器。它有一些配置设置: Template.template_containing_AceTextEditor.configuration = function(){ return function(editor){ if (Session.get('text') == "something") //here I want it to be react
Template.template_containing_AceTextEditor.configuration = function(){
return function(editor){
if (Session.get('text') == "something") //here I want it to be reactive
{
//do something every time 'text' changes
}
}
}
我也不想丢失包含AceTextEditor.configuration的Template.Template,因为它连接到我正在使用的包。好吧,你可以通过几种方式使代码反应,一种是将反应代码放入
Tracker.autorun
Tracker.autorun(function(){
if (Session.get('text') == "something") //this will run every time session text changes
{
//do something every time 'text' changes
}
})
确保将跟踪程序加载到项目中。您是否尝试过使用帮助程序?一旦您定义了助手(它是被动的),您就可以在带有{{#if something}的把手中使用它