Definiendo variable en Meteor.js
Cuando defino la variablelists
como se muestra a continuación y escribalists
En la consola, me sale el 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
});
}
Funciona solo si declaro.lists
como una variable global:
lists = new Meteor.Collection('Lists');
Pregunta: ¿Por qué debe ser un ámbito global?