1

我正在尝试将 angular-meteor 与 Meteor 一起使用,并按照https://www.meteor.com/tutorials/angular/collections中的教程进行操作

我有以下代码文件:

索引.html

<body ng-app="web-alerts">
  <div ng-include="'client/index.ng.html'"></div>
</body>

客户端/index.ng.html

<div ng-controller="AlertsListCtrl">
    <h1>Tasks:</h1>
    <ul>
        <li ng-repeat="webAlert in tasks">
            <b>{{webAlert.title}}</b>
            <p>Url: {{webAlert.url}}</p>
            <p>Emails: {{webAlert.emails}}</p>
            <p>Keywords: {{webAlert.keywords}}</p>
            <p>Frequency: {{webAlert.frequency}}</p>
        </li>
    </ul>
</div>

客户端/app.js

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


if (Meteor.isClient) {
  angular.module('web-alerts', ['angular-meteor']);

  angular.module('web-alerts').controller('AlertsListCtrl', ['$scope', '$meteor',
    function($scope, $meteor) {
      $scope.tasks = $meteor.collection(Tasks);
    }
  ]);
}

在 MongoDB 中,我向集合中添加了一些项目。

流星:PRIMARY> db.tasks.find()

{“_id”:ObjectId(“55fe7cbc330d5b4cfb52ed9e”),“title”:“aaa yyy zzzz”,“description”:“desc 在这里”,“url”:“ http://abcd.com ”,“keywords”: “abcd,efgh,ijkl”,“电子邮件”:“”,“频率”:10}

But I don't see the collection data in the UI. If I assign a static array to $scope.tasks in controller, it works fine.

What could be the issue?

Thanks in advance.

4

1 回答 1

0

Solved it by moving client/app.js to the root folder.

Can someone explain what could be the problem?

于 2015-09-20T10:02:27.787 回答