Hello,

I am working on one project(AngularJS+PHP) where I use one database for 
users login (params about users/clients and their databases) and the other 
database for user/client(every user has own database).
I want when I login in also connect to correct database
I'm login in successfully with some client account, catch db parameters for 
client database, but when I need to connect to corresponding client 
database it's not working.

I use service:

app.factory('loginService', function ($http, $location, sessionService) {
    return{ 
.............

          fetchuser: function () {
                  var usr = $http.get('model/fetch.php');
                 return usr;
                },
          fetchdbdata: function (dbdata) {
                  var usrdb = $http.post('model/fetchDB_data.php', dbdata);
                  return usrdb;
               }
................
           }
});

and corresponding controller:

app.controller('homeCtrl', ['$scope', 'loginService', '$location',  
function ($scope, loginService, $location) {
        var dbdata;
      
        var userrequest = loginService.fetchuser();
        userrequest.then(function (response) {
            $scope.usr = response.data[0];          //take users data, 
database params   
          
                                                               //in 
console  dbdata return correct object
                               dbdata = {
                                                      host_name: 
$scope.usr.host_name,
                                                      database_name: 
$scope.usr.database_name,
                                                      user_db: 
$scope.usr.user_db,
                                                      password_db: 
$scope.usr.password_db
                                                };       
/* ***************************************
if i use manually data like:
 dbdata = {
                host_name: "mysql333****",
                database_name: "datab*****",
                user_db: "ucdb_gp****",
                password_db: "^ucdb#*****"
            };

it works, and in console bellow return correct object and result. I don't 
understand why.

*******************************************/       
            
                                              var userrequestdb = 
loginService.fetchdbdata(dbdata);
                                                   
userrequestdb.then(function (response) {
                
                                                  $scope.usrdb = 
response.data[0];
                                                 
console.log($scope.usrdb);         //in console return E - nothing
                                            });
        });

 }]); 

Any advice would be helpful.

Greetings from Dule.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to