I am using iron:router@1.0.0-pre3 with meteor 9.3.1.
Template code:
<head>
<title>ironman</title>
</head>
<body>
</body>
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
Javascript code:
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault("counter", 0);
Template.hello.helpers({
counter: function() {
return Session.get("counter");
}
});
Template.hello.events({
'click button': function() {
// increment the counter when button is clicked
Session.set("counter", Session.get("counter") + 1);
}
});
Router.route('/', function() {
this.render('hello');
});
}
The route defined above doesn't work.
However, if I place the route definition outside if (Meteor.isClient) {
it starts working.
Is this by design? Please advise.