I am utilizing a service to facilitate data sharing between two controllers and retrieve a list of data:
myApp.service('DataService', function($http) {
this.data = [];
this.loadData = function() {
$http.get('/api/data').success(function(data) {
this.data= data;
})
};
});
This service is then called in my controller:
myApp.controller('appController', function($scope, DataService) {
$scope.DataService= DataService;
DataService.loadData();
});
The data should be displayed here:
<div ng-controller="appController">
<li ng-repeat='item in DataService.data'>
<a href="#item/{{item.ID}}"> View Item</a>
</li>
</div>
However, when running this code, nothing appears on the screen. I have checked with alert boxes and confirmed that the data list contains the correct information, yet it fails to display.