angular js从url获取数据

时间:2018-01-01 05:57:03

标签: angularjs

我是角度j的新手。我正在尝试从url获取数据。我知道如何从单个数组中获取json中的数据。但是如果json有很多数组,那么如何获取它?

例如: json如下:

{
    "Details": [{
        "approved": [{
            "count": "2124",
            "type": "Approved ",
            "desc": "New registration"
        }, {
            "count": "902",
            "type": "Deemed approved ",
            "desc": "New registration"
        }, {
            "count": "60",
            "type": "Approved ",
            "desc": null
        }, {
            "count": "5",
            "type": "Deemed approved ",
            "desc": null
        }, {
            "count": "29",
            "type": "Approved ",
            "desc": null
        }]
    }, {
        "pending": [{
            "count": "492",
            "type": "Amendment of core fields"
        }, {
            "count": "18",
            "type": "New registration"
        }, {
            "count": "1",
            "type": null
        }]
    }, {
        "rejected": [{
            "count": "29",
            "type": "New registration"
        }]
    }, {
        "resubmit": [{
            "count": "9",
            "type": "New registration"
        }]
    }]
}

1 个答案:

答案 0 :(得分:0)

假设您发送请求如下:

$http.get('/data').then(function(response) {
    response // your JSON
});

现在在内部响应中,您将把整个JSON作为javascript对象。所以你可以按如下方式使用它:

response.Details.approved[0].count // 2124
response.Details.pending[0].count // 492