【发布时间】:2018-01-30 06:15:34
【问题描述】:
我有一个 JSON 响应,我想按以特定单词或字母开头的命令。
我需要它对以"ItenaryFor": "Sightseen" 开头的 ItenaryFor 进行排序
请检查以下来自 API 的 JSON 响应。
这是我的 JSON:
{
"resultCode": 1,
"resultData": {
"Itinary": [
{
"ItenaryFor": "Transfer",
"Icon": "motel",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Phi Phi Island, Phuket City Tour",
"BackgroundImg": ""
},
{
"ItenaryFor": "Sightseen",
"Icon": "holiday",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Phi Phi Island, Phuket City Tour",
"BackgroundImg": ""
},
{
"ItenaryFor": "Sightseen",
"Icon": "holiday",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Phi Phi Island, Phuket City Tour",
"BackgroundImg": ""
},
{
"ItenaryFor": "Hotel",
"Icon": "motel",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Phi Phi Island, Phuket City Tour",
"BackgroundImg": ""
},
{
"ItenaryFor": "Hotel",
"Icon": "motel",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Phi Phi Island, Phuket City Tour",
"BackgroundImg": ""
},
{
"ItenaryFor": "Hotel",
"Icon": "motel",
"Comment": null,
"Iscustomsave": true,
"TourDelight": null,
"BackgroundImg": null
},
{
"ItenaryFor": "Sightseen",
"Icon": "holiday",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Coral Island",
"BackgroundImg": ""
},
{
"ItenaryFor": "Hotel",
"Icon": "motel",
"Comment": null,
"Iscustomsave": true,
"TourDelight": "Coral Island",
"BackgroundImg": null
}
]
}
}
请给我建议。
【问题讨论】:
-
为什么要投反对票?
-
你能详细解释一下
I need it to orderby ItenaryFor which starts with "ItenaryFor": "Sightseen"吗? -
@Pengyy 作为响应,它有键
ItenaryFor我需要具有值"ItenaryFor": "Sightseen"的记录首先开始意味着给它索引 0,1,2 -
为什么投反对票?您的问题太宽泛,只是列出了您的要求,并没有显示您的任何研究或努力。问题要么是关于排序并且它是重复的,要么是关于在 Angular 中构建一个管道,这在文档中得到了充分描述。在任何情况下,使用管道进行排序都不是一个好主意(这在documentation 中也有明确说明)。
-
您知道
orderBy已从 Angular 中删除,但您不知道为什么?阅读管道页面。
标签: angular ngfor angular-pipe