简体   繁体   English

如何在没有火焰模板的情况下使用角流星将参数传递给助手

[英]How pass parameter to helpers using angular-meteor without blaze template

This was possible with Blaze: how do I have to do it in angular-meteor without blaze template? 使用Blaze可以做到这一点:如何在没有blaze模板的情况下在角流星中做到这一点? Kindly help me 请帮助我

  Template.dummy.helpers({
  getImage: function(imageId) {
  return Images.findOne(imageId);
       }
       });

    {{ getImage '1234' }}

How this will happened in helpers of angular-meteor kindly correct my syntax if I am making any mistake as I am new to angular-meteor 如果我犯了任何错误,因为我是角流星的新手,这在角流星的助手中将如何发生?

This is my code: 这是我的代码:

<tr  class="ng-scope" align="center" ng-repeat="wordsList in addBundle.words(bundles)">
   this.helpers({
                words: (bundles) => {
                return words.find({});
    }
   });

So in angular-meteor there is no need to pass parameters to the helpers because you can and should use regular Angular's scope variables. 因此,在angular-meteor中,无需将参数传递给助手,因为您可以并且应该使用常规Angular的范围变量。

In your case, you also want to make them reactive (trigger an update in Meteor) so you should add getReactively when you use them. 对于您的情况,您还希望使它们具有反应性(在Meteor中触发更新),因此在使用它们时应添加getReactively

Here is an example of your need: 这是您需要的一个例子:

<tr  class="ng-scope" align="center" ng-repeat="wordsList in
    words">

this.bundles = 'some bundle thing';

this.helpers({
  words: () => {
    return words.find({bundles: this.getReactively('bundles')});
  }
});

of course, if querying bundles from words requires more complex query, you can use my example with any other Mongo query you like. 当然,如果从单词查询捆绑包需要更复杂的查询,则可以将我的示例与任何其他喜欢的Mongo查询一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM