[英]How pass parameter to helpers using angular-meteor without blaze template
使用Blaze可以做到這一點:如何在沒有blaze模板的情況下在角流星中做到這一點? 請幫助我
Template.dummy.helpers({
getImage: function(imageId) {
return Images.findOne(imageId);
}
});
{{ getImage '1234' }}
如果我犯了任何錯誤,因為我是角流星的新手,這在角流星的助手中將如何發生?
這是我的代碼:
<tr class="ng-scope" align="center" ng-repeat="wordsList in addBundle.words(bundles)">
this.helpers({
words: (bundles) => {
return words.find({});
}
});
因此,在angular-meteor中,無需將參數傳遞給助手,因為您可以並且應該使用常規Angular的范圍變量。
對於您的情況,您還希望使它們具有反應性(在Meteor中觸發更新),因此在使用它們時應添加getReactively
。
這是您需要的一個例子:
<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')});
}
});
當然,如果從單詞查詢捆綁包需要更復雜的查詢,則可以將我的示例與任何其他喜歡的Mongo查詢一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.