Reputation: 189
I'm new to meteor and I'm trying to run the very beginners tutorial and I'm having troubles reading data from a collection.
Here's my js
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import { Tasks } from '../../api/tasks.js';
import template from './todosList.html';
class TodosListCtrl {
constructor($scope) {
$scope.viewModel(this);
this.helpers({
tasks() {
return Tasks.find();
}
})
}
}
export default angular.module('todosList', [
angularMeteor
])
.component('todosList', {
templateUrl: 'imports/components/todosList/todosList.html',
controller: TodosListCtrl
});
and I have declared my collection like this (imports/api/tasks.js):
import { Mongo } from 'meteor/mongo';
export const Tasks = new Mongo.Collection('tasks');
I'm sure I'm missing something simple, will accept any help.
Upvotes: 0
Views: 47
Reputation: 2975
you need to be able to access the scope. in your component, you shoud have controller: ['$scope', TodosListCtrl]
Then if you insert a new task, you will see it db.tasks.insert({ text: "Hello world!", createdAt: new Date() });
Upvotes: 1