【发布时间】:2019-12-13 22:07:45
【问题描述】:
data-sharing.service.ts
public httpGetAll(owner: any) {
return this.http.get(`${this.url}/${owner}`, this.httpOptions).pipe(
catchError(e => {
throw new Error(e);
})
);
}
public httpGetAllBy(id: number, byId:string, owner: any) {
return this.httpGetAll(owner).subscribe(data => {
Object.keys(data).map(function(key) {
return data[key].filter(x => x[byId] === id);
});
})
station.service.ts
getStationsByOrg(id) {
return this.dataSharing.httpGetAllBy(id, 'orgId', 'station');
}
managestation.component.ts
getStationsByOrg(id) {
this.sta = this.staService.getStationsByOrg(id);
}
managestation.component.html
<ion-content class="body">
<ion-button expand="block" (click)="onAddStation()">Add Station
<ion-icon name='add' slot="end"></ion-icon>
</ion-button>
<ion-list>
<ion-item *ngFor="let s of sta">
<ion-label>{{ s.name }}</ion-label>
<ion-label>{{ s.orgId }}</ion-label>
<ion-icon name='create' slot="end" (click)="onEditStation(s.id)"></ion-icon>
<ion-icon name='trash' slot="end" (click)="onDeleteStation(s.id)"></ion-icon>
</ion-item>
</ion-list>
</ion-content>
错误
错误错误:“[对象对象]” Angular 11 core.js:4002
如何获取 managestation.component.ts 中 httpGetAllBy 的值并将其分配给 this.sta。 ?
【问题讨论】:
标签: angular typescript ionic-framework