Ionic multiple http.get request

hi there, i try to learn how can i put 2 different http.get request in the same result. For example i have 2 http.get query like this :

$scope.query1= $http.get("http://www.mywebsite.com/api1.php");
$scope.query2= $http.get('http://www.mywebsite.com/api2.php', {params:{userid:userid}});

Then i try to get results like this :

  $q.all([$scope.query1, $scope.query2]).then(function(results) {
      $scope.datas=results.data;
  });

And i put in ng-repeat in view file but i can not get any data in my view. There is a empty page in my app. so anybody know how can i do this?

best regards.

your problem may be any one of your get-request return empty value!
just log your data using console.log("$scope.datas"); ,and make sure that you have proper values

thanks for the answer when i look console.log it gives undefined. but i can get datas by this query with ng-repeat :

  $http.get("http://www.mywebsite.com/api1.php").then(function(results) {
    $scope.datas=results.data;
  })

But when i use q.all with 2 queries there is no data. Any idea about this issue?

ok, log the two query seperately and check each has valid data!
And let me wand to know one thing for what you bind the result of two query in a single variable?
And Check Both the query return array Type?

actually i try to make comparison with these 2 datas. First query list all records and second query search for the favourites (added by user). If data_id is in the favourites (in db mysql) check the box near the record list in view. So if i get datas from these 2 queries, i will use if else in my view and if records equals the check box will be checked by class which i used for div.i hope i can explain the situation. I try to find a solution about 2 mounts but i couldn’t find the way.

@parabahis,

I think $q.all() only accepts promises but as looking at your code it seems like your $http.get() methods are not returning any promise. That may be issue. Try to re structure your $http.get() request call.

actually i try to make comparison with these 2 datas. First query list all records and second query search for the favourites (added by user). If data_id is in the favourites (in db mysql) check the box near the record list in view. So if i get datas from these 2 queries, i will use if else in my view and if records equals the check box will be checked by class which i used for div.i hope i can explain the situation. I try to find a solution about 2 mounts but i couldn’t find the way.

If you give the code for this explanation then it would help everyone to understand your need better also anyone can suggest some alternate way for achieving your goal.