我有一条收集一些数据的路线。
Router.map(function () {
this.route('Players.guild', {
path: '/players/guild/:guildId',
template: 'GuildPlayerList',
waitOn: function () {
return Meteor.subscribe('guild_players', this.params.guildId);
},
data: function () {
return Players.find({ guildId: this.params.guildId });
}
});
});
然后,我有一个简单的模板
template(name="GuildPlayerList")
+ionList
+each this
+ionItem avatar=true ion-data-modal="_playerModalView"
img(src="{{ imageId store='PlayerThumbnails' }}" alt="{{ name }}")
h2 {{ name }}
template(name="_playerModalView")
// I want the current player in the +each to push its context of this here
+ionModal title="{{ name }}"
但是,问题是,当我加载模式时,this
的上下文似乎发生了变化。在其他情况下,我使用 _.bind
来推送 this
的上下文,但是如何使用 blaze 模板来完成此操作?
最佳答案
我不完全遵循您的语法,并且您没有解释 ion
的内容是什么,但在常规 html 语法中,您可以简单地向动态包含的模板提供数据参数,如下所述在
http://docs.meteor.com/#/full/template_dynamic ,所以在你的情况下(但html语法):
{{> _playerModalView data=this}}
关于javascript - 将 `this.data` 的上下文转移到 Blaze/Meteor 中的其他模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30124795/