Reputation: 73
i'm using ionic framework for mobile apps which work with angular js .. i had error when calling ajax data (factory,controller) ..
when reload it gives me this error "Provider 'stations' must return a value from $get factory method."
some of code :
enter cod //services.js
angular.module('starter.services', [])
.factory('stations',['$http',function($http){
var stations = []; $http.get(base_url+'api/stations/uid/'+uu_id).success(function(response){
stations = response;
return stations;
});
}])
//controllers.js
.controller('HomeCtrl',['$scope', 'stations', function($scope,stations){
$scope.stations = [];
stations.success(function(data){
$scope.stations = data;
});
}])e here
thanks for help :) ....
Upvotes: 0
Views: 44
Reputation: 73
I found the error >> all what i forgot to do is to return data from http get in factory services.js >>
.factory('stations',['$http',function($http){
var stations = [];
return $http.get(base_url+'api/stations/uid/'+uu_id).success(function(response){
stations = response;
return stations;
});
}])
Upvotes: 0