I'm currently working on passing data between controllers in Ionic with Angular. I know that using a factory is the best approach for this, but I keep encountering an error:
ReferenceError: setData is not defined
This is my code:
app.factory("Places", function() {
var Places = {};
Places.setData = function(places) {
Places.items = places;
};
Places.getItem = function($stateParams) {
return Places.item;
};
return{
setData: setData,
getItem:getItem
}
})
And here's the controller:
.controller('DetailsCtrl', function ($scope, $stateParams,Places) {
console.log('PlaceitemCtrl');
$scope.items=Places.getItem($stateParams);
});
Thank you for any assistance!