I'm currently facing challenges while working with data from a Collection in Angular-Meteor as I struggle to access it successfully.
Inside lib/collections.js, I have defined the collection:
UserMeta = new Mongo.Collection('userMeta');
In the server/publish.js file, it is published as follows:
Meteor.publish('userMeta', function() {
return UserMeta.find();
});
Subscribing to it in my client code located at client/scripts/controllers/settings.controller.js:
angular
.module('App')
.controller('SettingsCtrl', SettingsCtrl);
function SettingsCtrl($scope, $reactive) {
$reactive(this).attach($scope);
this.subscribe('userMeta');
//...
}
Exploring different subscription methods, I've decided to follow the most recent syntax for version 1.3.2 of Angular-Meteor: Subscribe API
Despite these efforts, when attempting to view the entire content of the collection, an empty array is returned:
console.log(UserMeta.find().fetch()); // =[]
Similarly:
console.log(UserMeta.findOne()); // =undefined
Interestingly though, running these commands directly in my browser's client console yields the expected results.
If anyone could provide a brief example illustrating how to effectively work with collections in this context, I would greatly appreciate it. Coming from a background with (pure) Meteor, I find myself puzzled by the differences encountered in Angular-Meteor.