I am asking the user to put in his details and submit his form which invokes a $http request to the server and delivers data.
app.service('Request',function($http,$location)
var baseUrl='/system/views/files.json';
var method='GET';
var details={}
this.flightReq=function(){
$http({
method:method,
url:baseUrl,
headers:{'Content-Type': 'application/x-www-form-urlencoded'},
params: {'dep':'a', 'arl':'b','number':'c', 'date1':'d'},
cache:true
})
.success(function(data,status){
console.log(data);
console.log(status);
$location.path('/resultpresentation/example');
details.flightDet=function(){ return data }
})
.error(function(data,status){
console.log(data||"Request failed");
console.log(status);
$location.path('/');
})
};
As the request shows, once it has been successful the user will be redirected to a new location. However on this result page I now seek to present the results. Therefore I have to store the results in a variable or function which I need to inject into the other module. The http request is injected to both modules, but the results should only be injected to the result module.
However, even though I inject the Service Request now and use $scope.data=Request.flightDet; in the controller, I am not able to present the data in the view. I can see now it is presented in the console. The flight results are only in the console (after success but are not accessible in the view or even controllers)
However, I do not know how to do this? I hope you can help me.
Best