我有使用Angular2来跟踪问题来从集合中订阅我的数据 .

当我加载列表并单击编辑时,它的工作正常 .

所有数据都在那里 . 但是,如果我改变了一些东西,服务器重新启动,因此页面正在重新加载,或者如果我只是尝试使用direkt链接进入该编辑页面,我在控制台中收到以下错误:

EXCEPTION:未捕获(在承诺中):错误:错误:0:0引起:无法读取未定义的属性'name'TypeError:无法读取未定义的属性'name'...

它必须与"subscribe"有关,如果我只是按照其工作的应用程序的链接,导致对象的所有数据都在那里, Collection.findOne(this._id) 正在工作 .

但重新加载后,整个列表的订阅缺失或类似的东西,我实际上不知道如何解决它 .

现在一些代码:

games.component.ts

...
        ngOnInit() {

            this.gamesSub = MeteorObservable.subscribe("games").subscribe(() => {
                this.games = Games.find({}).zone();
            });
        }
...

games-edit.component.ts

ngOnInit() {

    this.gameForm = this.fb.group({
        name: new FormControl(),
        questions: this.fb.array([])
    });
    this.game = Games.findOne(this.route.params._value.gameId); // Needed cause that hole MeteorObservable stuff is not working

    this.paramsSub = this.route.params
        .map(params => params['gameId'])
        .subscribe(gameId => {
            this.gameId = gameId;

            this.gameSub = MeteorObservable.subscribe('game', this.gameId).subscribe(() => {
                MeteorObservable.autorun().subscribe(() => {
                   return this.game = Games.findOne(this.gameId);
                });
            });

            this.setName(this.game.name);
            this.setQuestions(this.game.questions);
        });


}