【问题标题】:Angular Meteor: MongoDB collections are not shown in the UIAngular Meteor:MongoDB 集合未显示在 UI 中
【发布时间】: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


    【解决方案1】:

    通过将 client/app.js 移动到根文件夹来解决它。

    谁能解释可能是什么问题?

    【讨论】:

    • 当你有它在客户端文件夹中,尝试删除 isClient 的测试
    猜你喜欢
    • 1970-01-01
    • 2014-07-11
    • 1970-01-01
    • 2023-03-25
    • 2016-04-08
    • 2013-12-11
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多