When I define the variable lists as shown below and type lists in the console, I get the error ReferenceError: lists is not defined
var lists = new Meteor.Collection('Lists');
if (Meteor.isClient) {
Template.hello.greeting = function () {
return "my list.";
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
It works only if I declare lists as a global variable:
lists = new Meteor.Collection('Lists');
Question: Why must it be scoped global?