本文整理匯總了TypeScript中meteor/templating.Template類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Template類的具體用法?TypeScript Template怎麽用?TypeScript Template使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Template類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
Template['newTemplate'].rendered = function () {
};
Template['newTemplate'].destroyed = function () {
};
Template['newTemplate'].events({
'click .something': function (event: Meteor.Event, template: Blaze.TemplateInstance) {
}
});
Template.registerHelper('testHelper', function () {
return 'tester';
});
var instance = Template.instance();
var data = Template.currentData();
var data = Template.parentData(1);
var body = Template.body;
/**
* From Match section
*/
var Chats = new Mongo.Collection('chats');
Meteor.publish("chats-in-room", function (roomId: string) {
// Make sure roomId is a string, not an arbitrary mongo selector object.
check(roomId, String);
示例2: helloOnCreated
/**
* Created by Manas on 7/4/2016.
*/
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
Template.hello.onCreated(function helloOnCreated() {
// counter starts at 0
this.counter = new ReactiveVar(0);
});
Template.hello.helpers({
counter() {
return Template.instance().counter.get();
},
});
Template.hello.events({
'click button'(event, instance) {
// increment the counter when button is clicked
instance.counter.set(instance.counter.get() + 1);
},
});