小编Abh*_*jit的帖子

通过将参数传递给NGXS中的状态来选择值

我有一个包含JSON的状态,如下所示:

{id: "1", name: "ig1", description: "ig 11"}
{id: "5", name: "hhh", description: "hhh"}
{id: "6", name: "ggg", description: "hhh"}
Run Code Online (Sandbox Code Playgroud)

我需要从状态数组中选择ID = 1的数据

如何使用NGXS状态选择器完成此操作

以及如何在组件中访问它?


我的状态如下

食谱

0 : {id: "3", name: "Cake", image: "index.jpg", description: "Lorem Ipsum is 
simply dummy text of the printing a…ldus PageMaker including versions of 
Lorem Ipsum.", ingredients: "ig 1-1kg,ig 123-4kg"}
1 : {id: "16", name: "gfdg", image: "Chrysanthemum.jpg", description: 
"fhfgh", 
ingredients: "gdfg-4sfhs,ig 1-1kg"}
2 : {id: "17", name: "hfgh", image: "Jellyfish.jpg", description: "ghgfh", 
ingredients: …
Run Code Online (Sandbox Code Playgroud)

ngrx angular ngxs

0
推荐指数
1
解决办法
1597
查看次数

标签 统计

angular ×1

ngrx ×1

ngxs ×1