0
我使用流星, ,我有一個車把標記在我的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文件 。我沒有在我的網頁上找到任何東西。在我的控制檯中打印結果。
這是我調用服務器端方法時的主要問題,它首先將abc變量設置爲undefined。我現在正在循環運行。 – Sasikanth
是的,我明白這一點。你有沒有檢查我的建議?我非常確定這應該可以正常工作。 –
我寫了一個存根方法,它返回「loading ..」字符串,它不起作用,仍然返回未定義的value.how來完成它。 – Sasikanth