Reputation: 13
coming from this working example: http://jsfiddle.net/h22f7596/ , I am trying to display the content of a json-file from my own OData Service in AngularJS.
HTML:
<div ng-repeat="Adressen in results">
{{Adressen.Street}}
<strong style="float:right">
{{Adressen.PLZ}}
</strong>
</div>
</div>
JS:
var myModule = angular.module("MyModule",['ODataResources']);
myModule.controller("MyController",function($scope,$odataresource){
$scope.results =
$odataresource("https://xsgeos0015309874trial.hanatrial.ondemand.com/s0015309874trial/xsgeo/geotabelle/geoDB/GeotabelleODataService.xsodata/Adressen", [],
{
odata:{
method: 'GET',
isArray: true,
transformResponse: function (data) {
return angular.fromJson(data).value;
}
}
})
.odata()
.format("json")
.filter("Street", "Kölner Straße")
.filter("Hausnummer", "22")
.take(5)
.query();
});
I dont know why no data is displayed, because in Chromes console, I can see that the OData request is transferred succesfully, but it is not displayed in my controller and when I look at console.log($scope.results) it shows me an empty array.
Please take a look at my example and tell me what I did wrong: http://jsfiddle.net/h22f7596/123/
Thank you in advance.
/edit: Updated Fiddle.
Upvotes: 0
Views: 258
Reputation: 7937
You were accessing the data wrong. If you would have printed the entire object you would have seen:
Object: {
d: {
results: {
....
}
}
}
Change your return to:
return angular.fromJson(data).d.results
Fiddle: http://jsfiddle.net/h22f7596/124/
Upvotes: 1