如何在角度以不同格式构造对象
我是新来的角。我正在尝试重组我从API响应中获得的对象。我需要将当前对象构造为所需的对象。
这是下面的当前对象
let temp = {
"imagesList": {
"de": [{
"path": "",
"text": "desc text"
},
{
"path": "",
"text": "desc text"
}],
"en": [{
"path": "",
"text": "desc text"
}]
}
}
是所需的对象,从上面定义的当前对象
let temp = [
{
"path": "",
"description": [
{
"language": "en",
"text": "desc text"
}
]
},
{
"path": "",
"description": [
{
"language": "de",
"text": "desc text"
}
]
},
{
"path": "",
"description": [
{
"language": "de",
"text": "desc text"
}
]
},
]
如何使用Angular中的Typescript实现此目标。 沙盒 link 提前致谢
I'm new to angular. I'm trying to restructure the object which I'm getting from the API response. I need to structure the current object to desired object.
This is the Current Object
let temp = {
"imagesList": {
"de": [{
"path": "",
"text": "desc text"
},
{
"path": "",
"text": "desc text"
}],
"en": [{
"path": "",
"text": "desc text"
}]
}
}
Below is the Desired Object which is needed from the Current Object defined above
let temp = [
{
"path": "",
"description": [
{
"language": "en",
"text": "desc text"
}
]
},
{
"path": "",
"description": [
{
"language": "de",
"text": "desc text"
}
]
},
{
"path": "",
"description": [
{
"language": "de",
"text": "desc text"
}
]
},
]
How to achieve this using typescript in angular.
Sand box Link
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里,您有解决方案:
顺便说一句:您将使用JavaScript完全相同。这并不是真正的角度或打字稿问题;
here you have the solution:
BTW: you would do it exactly the same with javascript. It's not really an angular or typescript question;