【发布时间】:2019-05-31 21:02:58
【问题描述】:
我创建了一个带有 Angular 7 前端的 ASP.NET Core Web Api 后端。 Api 中的一种方法可以将对象或数组返回给 Angular 服务。如何根据返回的数据类型路由到特定的 observable?我是 Angular 的菜鸟,因此我们将不胜感激。
Angular service call to Api:
getLinksFromSitus(situs: any) {
this.http.post(this.baseUrl + 'getLinksFromSitus', situs).subscribe(data =>
this.apiData.next(data)
);
}
Portion of Web Api that returns array if more than one APN present:
// if more than one item in list, get status information for each and return list to user to select appropriate apn
if (propApn.Count > 1)
{
return Ok(propApn);
}
Portion of same method to return object if only one value for APN:
var resultsModel = new Results
{
ArcGisLink = arcGisLink,
HistInfoLink = histInfoLink,
PropInfoLink = propInfoLink
};
return Ok(resultsModel);
【问题讨论】:
标签: rxjs angular7 asp.net-core-webapi