0

I have problem with outputting data from JSON file

{
"movie": {
    "RowCount": 0,
    "Result": [
        {
            "movieID": "124",
            "moviename": "Hello"
        },
        {
            "movieID": "123",
            "moviename": "World"
        }
    ]
}
}

I dont know why the {{}} statement wont work with this kind of JSON file. if the JSON File with another format like following

{
"discCount": 0,
"results":[
    {
        "disccode": "ABC123"
    },
    {
        "disccode": "ABCD123"
    }
]
}

it works perfect just by calling the {{variablename.disccode}}

can anybody help me please? thank you

1 Answer 1

0

From your edit, it appeared that you are resolving the wrong property. You should resolve :

defer.resolve({
    data: response.movie.Result,         
    rowCount: response.movie.RowCount 
});

Then, because the controller stores the data in $scope.movies, the following ng-repeat will be ok :

<tr data-ng-repeat="movie in movies">
    <td>{{movie.ID}}</td><td>{{movie.moviename}}</td>
</tr>
Sign up to request clarification or add additional context in comments.

9 Comments

so sir how to edit the function that retrieve the data from JSON file? because currently i am just using $scope.movies = response.data.. and looks like it is not a correct function, and i dump it in console log, it says undefined
What do you have in response ?
success(function(response){ defer.resolve({ data: response.results, albumCount: response.albumCount }); }).
If you do a console.log(response) before the defer.resolve(..) what is the output ?
it says the movie is an object sir, thereafter it displays the result in arrays. while for the second type of JSON file, it will directly display the results
|

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.