angular - 以角度返回一个空数组
问题描述
我有一个作为 getSectionDetails 的服务调用。当我在 component.ts 类中调用它时,它只返回一个空数组。我正在从上一页获取 eventId。它将在控制台中打印。所以进入下一页(节页)是没有问题的。我需要通过 getSectionDetail 调用发送 eventId。当我进入版块页面时,我需要获取版块详细信息。但在这种情况下,当我进入部分页面时,它返回一个空数组
import {AfterViewInit, OnDestroy} from '@angular/core';
import {Component, ViewEncapsulation, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Section} from '../../../interfaces/section';
import { SectionService } from 'app/services/section.service';
@Component({
selector: 'select-section',
templateUrl: './select-section.component.html',
encapsulation: ViewEncapsulation.None
})
export class SelectSectionComponent implements OnInit, AfterViewInit{
eventId: string;
sectionList: Section[] = [];
constructor(private activatedroute: ActivatedRoute,
private _router: Router,
private _sectionService: SectionService) {
this.eventId = this.activatedroute.snapshot.paramMap.get('id');
}
ngOnInit() {
}
ngAfterViewInit() {
this.getSectionDetails();
}
getSectionDetails() {
this._sectionService
.getSectionDetails(this.eventId)
.subscribe((sectionList: Section[]) => {
this.sectionList = sectionList;
console.log(this.sectionList);
});
}
}
解决方案
推荐阅读
- amazon-web-services - Lambda SDK 调用无响应
- node.js - writing nodejs applications in kotlin with intellij idea ce
- xml - 检索上周在 Taleo 中接受的报价
- c++ - 将 "enum: int64_t" 值写入 std::ostringstream 会将其截断为 int
- azure - 将 Linux 服务器连接到 Azure Log Analytics 工作区的代理的名称是什么?
- java - 在 JavaFX 中使用动画计时器时如何解决帧率下降问题?
- python - 使用 struct.pack 和 struct.unpack 的问题
- emacs - org-mode 表头格式未正确对齐
- c# - 具有可定义列的 WPF Datagrid UserControl
- netsuite - NetSuite CASE WHEN 不工作,即使所有单独的语句都有效