使用Json的AngularJs读取变量?

时间:2016-05-19 17:07:56

标签: html angularjs json

我想阅读"标题" AngularJs提交的提交怎么做?

[
    {
      "conference": "International Web Comics",
      "acronym": "IWCC 2016",
      "chairs": [
        "Jessica Jones <jessica.jones@alias.com>", 
        "Vanessa Ives <vanessa.ives@hell.com>",


       ],
      "submissions": [
        {
            "title": "The Microsoft Academic Research -- SAVE-S Keynote Talk",
            "authors": [
                "Ale <alee@example.com>"
            ],
            "url": "wade-savesd2016.html",
            "reviewers": [
                "Samanta  <sioni@un.it>",

            ]

2 个答案:

答案 0 :(得分:1)

a=[ { "conference": "International Web Comics", "acronym": "IWCC 2016", "chairs": [ "Jessica Jones ", "Vanessa Ives ",

],
"submissions": [
{
    "title": "The Microsoft Academic Research -- SAVE-S Keynote Talk",
    "authors": [
        "Ale <alee@example.com>"
    ],
    "url": "wade-savesd2016.html",
    "reviewers": [
        "Samanta  <sioni@un.it>",

    ]
}]
}]

submission_title = a[0].submissions[0].title  //accessing submission title 

答案 1 :(得分:0)

它与angularJS无关。您只需要使用点(。)运算符解析javascript对象(JSON)。

您可以直接使用访问对象属性。 (点)运算符,如果属性是数组,则需要通过索引访问数组。

就像你的情况一样

var obj = [ { "conference": "International Web Comics", "acronym": "IWCC 2016", "chairs": [ "Jessica Jones ", "Vanessa Ives ",

   ],
  "submissions": [
    {
        "title": "The Microsoft Academic Research -- SAVE-S Keynote Talk",
        "authors": [
            "Ale <alee@example.com>"
        ],
        "url": "wade-savesd2016.html",
        "reviewers": [
            "Samanta  <sioni@un.it>",

        ]

您可以直接访问会议

obj.conference

但是要访问提交标题,您需要使用

obj.submissions[0].title