0

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]>",

            ]
3
  • 1
    Where is this Json? Is it actually a javascript object, or is it in a file? If it's in a file, is it on local disk (use FileReader() ) or a web resource (use $http)? Once you read it as a string you can use var obj = angular.fromJson() Commented May 19, 2016 at 17:41
  • It is a file.I try to make with this line code, but I don't receive the "title" with this <section class="row"> <!-- Blog Sidebar Widgets Column --> <section class="col-md-4"> var eventi = angular.module('eventsPopulate', []) eventi.controller('ctrlEventi', function($scope,$http) { $http.get("events.json") .success(function (response){ $scope.arrayConferenze = response; }); Commented May 19, 2016 at 19:33
  • Try using $scope.arrayConferenze = angular.fromJson(response) to turn it into an object, then you should be able to do arrayConferenze[0].submissions[0].title Commented May 20, 2016 at 9:43

2 Answers 2

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

    ]
}]
}]

submission_title = a[0].submissions[0].title  //accessing submission title 
Sign up to request clarification or add additional context in comments.

3 Comments

I can't modify a json file. How can I do it ?
i didn't understand what you are trying to say, could you please describe your problem in detail.. :)
This is a file jason that I have in my folder. With my class I'will try to take only the "title " in my app.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.