現在の日付を表示したい。私は次のコードを書いたが、変数value
の値を表示していない。流星の現在の日付を表示する
<head>
<title>my_first_app</title>
</head>
<body>
<h1>Hello from Pakistan</h1>
{{> hello}}
{{> date}}
</body>
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
<template name="date">
<p>The time now is {{value}}.</p>
</template>
JS:
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);
}
});
var value = new Date();
Template.date.helpers(value);
}
if (Meteor.isServer) {
Meteor.startup(function() {
// code to run on server at startup
});
}
以下のようなもの...' Template.date.helpers({値:値}を書くことができます) '、さらには' Template.date.helpers({value}) 'のようなものです。 –