angular - 另一个不是订阅的语法
问题描述
目标:
检索数据。
问题:
是否有另一种方法来检索数据而不是使用语法代码“订阅”?
信息:
我是 Angular 的新手
Component.ts
this._testService.SentApplicationByIdPersonprofileid(personprofilid).subscribe(data => {
this._sentApplicationByIdPersonprofileid = data as SentApplicationByIdPersonprofileid[];
});
service.ts
SentApplicationByIdPersonprofileid(id: number)
{
return this._http.get(url + 'api/SentApplicationByIdPersonprofileid/' + id);
}
asp.net core API
public ActionResult<IEnumerable<SentApplicationByIdPersonprofileid>> SentApplicationByIdPersonprofileid(int id)
{
....
....
....
}
解决方案
这是获取数据的最简单方法。每个观察者模式在幕前或幕后都遵循 pub/sub 设计模式。就像在 redux 中一样,您不需要显式地键入 subscribe 来获取数据,但是 redux 会在幕后为您编写订阅。对于大型应用程序,更好的方法是使用 ngrx/store。您通常不使用 subscribe 方法,而是调度操作和 ngrx 为您调用 subscribe 。
这是ngrx/store的链接: https ://ngrx.io/guide/store
推荐阅读
- javascript - 使用 react redux 加载栏包,我试图显示加载栏组件
- c# - Get All The Child Details of Parent Menu
- python - 如何通过 Selenium 和 python 点击带有 find_element_by_* 的链接
- python - 将 PyTorch 张量转换为 python 列表
- javascript - 为什么道具变量不能被破坏?
- swift - UITextField 必须有最少的字符才能激活 UIButton
- javascript - 循环后返回对象数组的值
- java - ListView 重叠折叠工具栏
- r - 尝试用特定年份填充缺失的数据并按顺序填充。
- hadoop - Hadoop 3.1.1 仅显示一个活动数据节点