映射列表<;KeyValuePair<;字符串,字符串>&燃气轮机;从web服务到angular

映射列表<;KeyValuePair<;字符串,字符串>&燃气轮机;从web服务到angular,angular,Angular,我必须调用一个服务来获取返回keyvaluepair列表类型的数据 Task<List<KeyValuePair<string, string>>> GetItems(); Task GetItems(); 如果我有一个angular中的服务调用这个api,我该如何映射它呢?当您将List对象序列化为json时,您将看到如下所示的数组 [ { "Key":"string", "Value":"string"

我必须调用一个服务来获取返回keyvaluepair列表类型的数据

    Task<List<KeyValuePair<string, string>>> GetItems();
Task GetItems();

如果我有一个angular中的服务调用这个api,我该如何映射它呢?

当您将List对象序列化为json时,您将看到如下所示的数组

[
    {
        "Key":"string",
        "Value":"string"
    },
    {
        "Key":"string",
        "Value":"string"
    }
]
您可以像这样在AngularJS服务中解析它

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
    $http.get("welcome.htm").then(function (response) {
        var key1 = response.data[0].key;
        var value1 = response.data[0].value;
    });
});

如果我创建了一个属性为Key和Value的对象,并将其直接分配给响应,它会自动映射吗?this.myService.getKeyValueItems().subscribe((monthList)=>{this.keyValueObject=monthList;});我和angular 4 btw一起工作。。