Hi all!
I am struggling to get collection-helpers working with my Angular-Meteor-based app. Should these two go hand-in-hand or are there known problems?
Full description of what I tried so far can be found on SO.
TIA
Matt
Hi all!
I am struggling to get collection-helpers working with my Angular-Meteor-based app. Should these two go hand-in-hand or are there known problems?
Full description of what I tried so far can be found on SO.
TIA
Matt
Hi @Urigo!
Thanks for your reply. I saw that issue and tried what is described there, but it does not work for me, unfortunately.
In the SO post I linked to, you can see all my (relevant) code. I am trying to build a list view of quotes. For each quote, I want to show the full name of the author for that quote (it’s basically like the books and authors example in the package examples).
When I do {{quote.author().fullName()}}
in my list view template, I get that exact string as what seems to be verbatim output. So using the function reference does not work for me.
When I do {{quote.author}}, I get the ID of the author record, however.
So I am still at a loss here, unfortunately. Any ideas why it might not work in this case?
P.S.: I am happy to send a link to my full repo in case someone gets THAT interested
With the new Angular Meteor 1.3 release we are using collection-helpers just like the rest of the Meteor community so everything should be simpler now…
I’m trying to get dburles/meteor-collection-helpers package working with Angular Meteor 1.3 / ng-repeat. I have two collections.
Lists.attachSchema(new SimpleSchema({
title: {
type: String
},
archived: {
type: Boolean
},
createdAt: {
type: Date,
denyUpdate: true
},
sort: {
type: Number,
decimal: true,
optional: true
},
updatedAt: {
type: Date,
denyInsert: true,
optional: true
}
}));
and cards:
Cards.attachSchema(new SimpleSchema({
title: {
type: String
},
archived: {
type: Boolean
},
listId: {
type: String
},
members: {
type: [String],
optional: true
},
userId: {
type: String
},
sort: {
type: Number,
decimal: true
}
}));
I defined a collection helper as the following:
Lists.helpers({
cards() {
return Cards.find({
listId: this._id,
archived: false
}, {sort: [‘sort’]});
}
});
I’m using publish composite to get first the list, then cards associate via a subscription. Thats working hunky dory. But in my template when i can’t seem to figure out to get the equivalent of list.cards() working in my ng-repeat. Here’s a snip from my controller, and the relevant template markup.
$reactive(this).attach($scope);
//note this is composite publish this.subscribe('list', () => {
return [$stateParams.listId];
});
this.helpers({
lists: () => {
return Lists.findOne({_id: $stateParams.listId});
}
});
< class="" ng-repeat=“card in list.cards”></>
You can’t call list.cards() in ng-repeat, ng-repeat doesn’t work with functions
Calling as in example does nothing, but i believe thats because it returns a function.
Other older solutions involve just adding a scope function and querying, but that seems to not work and loose reactivity.
When i say something just like {{list.cards()}} i do get a cursor i believe back, not the results though.
Anything obvious? I’ve seen some others having problems with this same thing but in earlier versions of angular meteor with no success, hoping someone has figured this out. Thanks.
Adding a .fetch() to my List.helper() and calling list.cards() in the actually does work, but the reactivity doesn’t seem to work. I can add more cards and I have to refresh the page to get the update.