angular - 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);
}
});
}
解决方案
我的错。我错过了一个}。但它在以前的版本中工作。
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);
}
}
});
}
推荐阅读
- python - Python .NET 中的 VB.NET ReDim 数组
- amazon-web-services - 找不到 /bin/sh Docker
- php - 未命名的数组中的Wordpress和PHP循环?
- postgresql - 获取每个组的最大字段的整个记录
- node.js - node.js - 主页不加载,但其他页面加载
- python - Python pyautogui单击弹出按钮不起作用?
- javascript - 当存储在变量中时,Socket.io 发射到 socket.id 不起作用
- html - 如何通过双击从禁用状态启用选择标签?
- apache-kafka - kafka 的问题 - 结果“退出代码”失败,状态 = 1/FAILURE
- concrete5 - php7 xampp 上的 Concrete5 数据库导入问题