smnmtzgr
smnmtzgr

Reputation: 78

no database content is showing (Meteor, AngularJS, mongodb)

i created a "todolist" with angular-meteor (meteor add urigo:angular). This are the files which are involved:

config.js (ui-router file)

  .state('app.todolist', {
  url: '/todolist',
  title: 'Todolist',
  controller: 'TodoListController',
  controllerAs: 'tc',
  templateUrl: helper.basepath('todolist.ng.html'),
  authenticate: true
})  

todolist.ng.html (static file)

<h3>Todo - List
<small>Example app of a todo list.</small>
</h3>
<ul ng-repeat="task in tc.tasks">
    <li>{{task.text}}</li>
</ul>

todolist.js (Controller)

angular.module('angle').controller('TodoListController',
['$scope', '$meteor', 
function($scope, $meteor){
    var vm = this;

    vm.tasks = $meteor.collection(Tasks);
}]
);

the "tasks" collection is loaded in the "lib" folder and has documents inserted

meteor:PRIMARY> db.tasks.find()
{ "_id" : ObjectId("55bf7d98251a0c51417732bf"), "text" : "zweiter eintrag", "createdAt" : ISODate("2015-08-03T14:41:28.534Z") }
{ "_id" : ObjectId("55bf7dab251a0c51417732c0"), "text" : "zweiter eintrag", "createdAt" : ISODate("2015-08-03T14:41:47.045Z") }
{ "_id" : ObjectId("55bf7dac251a0c51417732c1"), "text" : "zweiter eintrag", "createdAt" : ISODate("2015-08-03T14:41:48.685Z") }
{ "_id" : ObjectId("55bf7dad251a0c51417732c2"), "text" : "zweiter eintrag", "createdAt" : ISODate("2015-08-03T14:41:49.003Z") }
{ "_id" : ObjectId("55bf7dad251a0c51417732c3"), "text" : "zweiter eintrag", "createdAt" : ISODate("2015-08-03T14:41:49.261Z") }

lib/js/databases.js

Tasks = new Mongo.Collection('tasks');

But when I run my app and click on the "Todolist" I can't see anything. It doesnt list any task.text... If I use a static array instead of mongodb everything works fine. (for example: vm.tasks = [{ text: "Task1" },{ text: "task2" }]; ).

But with mongodb noting is showing. I checked the database connection, this works. I dont get any errors, when loading the app and accessing the "Todolist".

Any ideas?

Regards, Simon

Upvotes: 2

Views: 202

Answers (1)

smnmtzgr
smnmtzgr

Reputation: 78

Ok problem is solved. I created the databases.js in the "myapp/client/lib" folder instead of the pure "myapp/lib" folder.

bad mistake... but its solved :) Thanks for help!

Upvotes: 2

Related Questions