【发布时间】:2015-12-17 03:21:03
【问题描述】:
我正在尝试将 angular-meteor 与 Meteor 一起使用,并按照 https://www.meteor.com/tutorials/angular/collections 的教程进行操作
我有以下代码文件:
index.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>
client/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 中,我向集合中添加了一些项目。
meteor:PRIMARY> db.tasks.find()
{ "_id" : ObjectId("55fe7cbc330d5b4cfb52ed9e"), "title" : "aaa yyy zzzz", "description" : "desc 到这里", “网址”:“http://abcd.com”,“关键字”:“abcd,efgh, ijkl", "电子邮件" : "", “频率”:10 }
但我在 UI 中看不到集合数据。如果我在控制器中为 $scope.tasks 分配一个静态数组,它工作正常。
可能是什么问题?
提前致谢。
【问题讨论】:
标签: angular-meteor