main.js 511 B

12345678910111213141516171819202122
  1. import { Template } from 'meteor/templating';
  2. import { ReactiveVar } from 'meteor/reactive-var';
  3. import './main.html';
  4. Template.hello.onCreated(function helloOnCreated() {
  5. // counter starts at 0
  6. this.counter = new ReactiveVar(0);
  7. });
  8. Template.hello.helpers({
  9. counter() {
  10. return Template.instance().counter.get();
  11. },
  12. });
  13. Template.hello.events({
  14. 'click button'(event, instance) {
  15. // increment the counter when button is clicked
  16. instance.counter.set(instance.counter.get() + 1);
  17. },
  18. });