【发布时间】:2014-02-17 14:27:00
【问题描述】:
我正在使用流星, 我的 html 中有一个车把标签
{{displayResult}}
在我的客户端 JS 文件中,我编写了这样的帮助程序和存根方法
辅助功能 *编辑*
displayResult:function(){
var abc;
var apiResultDependency = new Deps.Dependency();
Meteor.call('apiresult',function(e,result){
abc=result;
apiResultDependency.changed();
});
console.log(abc);
console.log(result);
apiResultDependency.depend();
return abc;//returning nothing
}
存根方法
Meteor.startup(function(){
return Meteor.methods({
apiresult:function(){
console.log("loading...");
}
});
});
而我的服务器代码与一个 API 连接并延迟结果,我的代码是
apiresult:function(){
var response = returnAllResult();//this gets the result from outside func. working good
return response;
}
我想从服务器端函数中获取结果,我想在 html 文件中显示 如何接收和显示它。我的网页中没有任何内容。在我的控制台中,它正在打印结果。
【问题讨论】:
标签: javascript meteor