Definindo Variável no Meteor.js
Quando eu defino a variávellists
como mostrado abaixo e digitelists
no console, recebo o erroReferenceError: 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
});
}
Só funciona se eu declararlists
como uma variável global:
lists = new Meteor.Collection('Lists');
Questão: Por que deve ser escopo global?