0

我玩了一个只从数据库读取的简单 Meteor Angular 2 应用程序。我有另一个更改数据库的应用程序。但是当数据库更改时,我在 Meteor 应用程序上遇到错误。

Exception in queued task: EXCEPTION: Error in client/match.html:0:19
ORIGINAL EXCEPTION: TypeError: Cannot read property 'league' of undefined
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'league' of undefined
at DebugAppView._View_MatchComponent0.detectChangesInternal (MatchComponent.template.js:101:59)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
at DebugAppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57415:44)
at DebugAppView.AppView.detectViewChildrenChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57346:34)
at DebugAppView._View_MatchesComponent1.detectChangesInternal (MatchesComponent.template.js:106:8)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
at DebugAppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57415:44)
at DebugAppView.AppView.detectContentChildrenChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57341:37)
at DebugAppView._View_MatchesComponent0.detectChangesInternal (MatchesComponent.template.js:65:8)
at DebugAppView.AppView.detectChanges (http://localhost:3001/packages/modules.js?hash=5bea6cc36ccb7076b2a2834b250a3c141ff0cd78:57326:14)
ERROR CONTEXT:
[object Object]

我正在使用自动发布哪个集合:

import {Mongo} from 'meteor/mongo';
export let MatchCollection = new Mongo.Collection('matches');

和角度分量:

export class MatchesComponent
{
    matches;
    constructor() {
        this.matches = MatchCollection.find();
    }
}

注意:Meteor Blaze 版本运行良好。我是 Meteor Angular2 的新手。

感谢所有帮助。

4

2 回答 2

1

我猜你正在使用*ngFor.

您可以使用这种更稳定的方式

this.matches = MatchCollection.find().fetch();

MatchCollection.find();返回Mongo.Cursor<any>

MatchCollection.find().fetch();返回Array<any>

奇怪,这个bug应该已经修复了……

于 2016-05-31T16:30:29.040 回答
0

看起来外部更改删除了league文档中的属性名称,您的 angular2 视图在某处使用了该属性名称。

通过查看文档meteor mongo以查看文档在被外部进程修改之前和之后在存储中的外观。

于 2016-05-30T13:35:51.797 回答