Your logic is correct, your mistake is in fact a common lie of JS: inside the callback function, the Meteor.callscope is thischanged and no longer refers to the template instance.
You need to use Function.prototype.bindand update the code:
Template.Home.onCreated(function () {
this.name = new ReactiveVar();
Meteor.call("getNames", function(error, result) {
if(error){
alert("Oops!!! Something went wrong!");
return;
}
this.name.set(result);
}.bind(this));
});
You can also use a local variable captured by the closure (you'll often see this style in JS projects):
Template.Home.onCreated(function () {
var template = this;
template.name = new ReactiveVar();
Meteor.call("getNames", function(error, result) {
if(error){
alert("Oops!!! Something went wrong!");
return;
}
template.name.set(result);
});
});