在我的 angular 应用程序中,我得到了如下所示的 Json 数据。
[{"id":"5","name":"Immidiate"},
{"id":"4","name":"30 days"},
{"id":"3","name":"21 days"},
{"id":"2","name":"14 days"},
{"id":"1","name":"7 days"},
{"id":"6","name":"Custom"}]
我需要一个像下面这样的输出,
[{"Name":"5","Data":"Immidiate"},
{"Name":"4","Data":"30 days"},
{"Name":"3","Data":"21 days"},
{"Name":"2","Data":"14 days"},
{"Name":"1","Data":"7 days"},
{"Name":"6","Data":"Custom"}]
这是我的代码
$rootScope.DashboardData["Name"] = widget.seriesname ;
delete $rootScope.DashboardData[widget.seriesname];
$rootScope.DashboardData["data"] = widget.dataname ;
delete $rootScope.DashboardData[widget.seriesname];
widget.chartSeries = $rootScope.DashboardData;
其中widget.seriesname 是“id”,widget.dataname 是“name”。
问题:密钥没有改变!