我正在开发一个流星应用程序,并试图遍历数据库以动态显示其数据,但无法这样做。

这是我的控制器,路线,集合和视图。

客户端/脚本/控制器/stocks.controller.js

angular
.module('stockAiApp')
.controller('StocksCtrl', StocksCtrl);

function StocksCtrl($scope, $reactive) {
$reactive(this).attach($scope);

this.helpers({
    nasdaq() {
            return Nasdaqs.find({});
        },
        nyse() {
            return Nyses.find({});
        },
        amex() {
            return Amexs.find({});
        }
});

////////////

}


客户端/脚本/routes.js

 .state('tab.stocks', {
        url: '/stocks',
        views: {
            'tab-stocks': {
                templateUrl: 'client/templates/stocks.html',
                controller: 'StocksCtrl as stocks'
            }
        }
    })


client / templates / stocks.html

<ion-item
        ng-repeat="stock in stocks.nasdaq"
        class="item"
        type="item-text-wrap"
        href="#">
            <p>{{stock.Symbol}},
               {{stock.Name}},
               {{stock.sector}}</p>
        </ion-item>


lib / collections.js

Nyses = new Mongo.Collection('nyses');
Nasdaqs = new Mongo.Collection('nasdaqs');
Amexs = new Mongo.Collection('amexs');

最佳答案

尝试将.fetch()与find()方法一起使用

09-07 16:19