Hey Guys,
I’m new to Ionic and i’m trying to convert the data from a local array on the demo app to using data from a json feed.
If i put the code into the controller directly i can pull items and display in the list. If i add the code into the services file and link to the function in the controller it doesn’t seem to return the data to the list and display.
Here is both my services and controller:
Controller:
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope) {
})
.controller('PlaylistsCtrl', function($scope, MenuFeed) {
$scope.items = [];
$scope.items = MenuFeed;
console.log($scope.items)
return $scope.items;
})
.controller('PlaylistDetailCtrl', function($scope, $stateParams) {
$scope.items = Friends.get($stateParams.playlistId);
})
Services:
angular.module('starter.services', [])
.factory('MenuFeed', function($http) {
var myHeader = {headers: {
'Application-id': 'HIDDEN',
'secret-key': 'HIDDEN'
}
};
$http.get('https://api.backendless.com/v1/data/menu', myHeader).success(function (data) {
console.log(data.data);
return data.data;
});
});
I’m not sure what’s broken but any help would be great. I tried to put it on codepen but i don’t know how to put the services file as a seperate file without paying.
Thanks