本文整理汇总了TypeScript中meteor/templating.Template.instance方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Template.instance方法的具体用法?TypeScript Template.instance怎么用?TypeScript Template.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/templating.Template
的用法示例。
在下文中一共展示了Template.instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
return Chats.find({ room: roomId });
});
示例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);
},
});