简体   繁体   中英

AngularJS json output format

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM