Simone Landi
Simone Landi

Reputation: 1

Read a variable with AngularJs from Json?

I want to read the "title" of submissions with AngularJs. How do it ?

[
    {
      "conference": "International Web Comics",
      "acronym": "IWCC 2016",
      "chairs": [
        "Jessica Jones <[email protected]>", 
        "Vanessa Ives <[email protected]>",


       ],
      "submissions": [
        {
            "title": "The Microsoft Academic Research -- SAVE-S Keynote Talk",
            "authors": [
                "Ale <[email protected]>"
            ],
            "url": "wade-savesd2016.html",
            "reviewers": [
                "Samanta  <[email protected]>",

            ]

Upvotes: 0

Views: 49

Answers (2)

Sandip Nirmal
Sandip Nirmal

Reputation: 2459

It has nothing to do with angularJS in specific. You just need to parse the javascript object (JSON) using dot (.) operator.

You can access objects property directly using . (dot) operator, if property is array then you need to access array by its index.

like in your case

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 <[email protected]>"
        ],
        "url": "wade-savesd2016.html",
        "reviewers": [
            "Samanta  <[email protected]>",

        ]

You can access conference directly as

obj.conference

but for accessing submissions title you need to use

obj.submissions[0].title.

Upvotes: 0

Nagender Rawat
Nagender Rawat

Reputation: 141

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 <[email protected]>"
    ],
    "url": "wade-savesd2016.html",
    "reviewers": [
        "Samanta  <[email protected]>",

    ]
}]
}]

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

Upvotes: 1

Related Questions