首页 > 解决方案 > ts 3.0.1 的 subscribe() 预期声明或声明

问题描述

我收到了预期的声明或声明。我最近更新了 ts 和 angular。

getTopics() {
    this._dataService.getTopics().subscribe(res => {
        this.topics = res;

        for (let i = 0; i < this.topics.length; i++) {
            if (this.topics[i]._id > this.max) {
                (this.max = this.topics[i]._id);
            }
    });
}

标签: angulartypescriptsubscription

解决方案


我的错。我错过了一个}。但它在以前的版本中工作。

getTopics() {
this._dataService.getTopics().subscribe(res => {
    this.topics = res;

    for (let i = 0; i < this.topics.length; i++) {
        if (this.topics[i]._id > this.max) {
            (this.max = this.topics[i]._id);
        }
    }
});
}

推荐阅读