簡體   English   中英

角度js從URL獲取數據

[英]angular js fetching data from url

我是angular js的新手,正在嘗試從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"
        }]
    }]
}

假設您發送請求的方式如下:

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

現在,在響應中,您將整個JSON作為javascript對象。 因此,您可以按以下方式使用它:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM