I\'m creating a personal website where I can keep updating content without having to manipulate the HTML
. I\'m trying to achieve this by simply loading and updating
Your json file has an array with the first and only element in the array being a json object. When .success()
fires, and data is passed into the lambda function, data is an array, not just json. All you have to do is access the zeroth element of the array.
So this:
.success(function(data) {
$scope.contents = data;
})
Should be this:
.success(function(data) {
$scope.contents = data[0];
})
Also, you should check data[0]
to make sure that it's json, and if it doesn't validate, you should probably call parseJSON(data[0])
on it.