Initialize some user parameters using Angularjs and Google Cloud Endpoints

Asked

Viewed 25 times

2

I am trying to initialize some user parameters using Angularjs and google cloud endpoints. Through a getProfile endpoint, I need to get user information like photo, description, age to show on screen. I can make a call of this type using a form and a button for example, what I’m not getting and make this call before the page is loaded, so when it is loaded I already have the information to show from the screen.

That’s kind of what I’m trying to do: (HTML)

          <div class="form-group">

            <label class="col-sm-3 control-label">Profile image</label>
            <div class="col-sm-9" ng-controller='initController'>
                <img src="{{userPicture}}" class="user-image-profile" alt="User Image">
            </div>
          </div>

(Angularjs)

controllers.initController = function($scope, $http){

$scope.userForm = {
        "userEmail" : $.cookie('auth') 
            };

gapi.client.igardenendpoints.getProfile($scope.userForm).execute(function(resp) {
    $scope.$apply(function () {

    if (resp.error) {
        $scope.backmessage.messagetext = "GetProfile Error!"
        console.log("error");

             } else {


    if (resp.userEmail == "TEMPLATE"){

            $scope.backmessage.messagetext = "Error please try again!"


    }else{

        $scope.userPicture = 'https://filiperebollo1986.appspot.com/serve?blob-key=AMIfv94gWb8w5nMQbY0aUjnef8-HlVMKN9P6wGcZClk0iX4Fg3WPEXtPZwcVBbjsPsYZJ6O9sVCG_0SHmIKtDcPCj1sUIgUVYTqhl9Db8WKpdpPp-8sjFrRXXcLuJyYLaFfeRxRi7RaH7iwuUBh57u-cwsgIFNtOJacSxQK38M_XCJMzm1ws9O0';
        console.log('acho que funcionou');

    }

    }
       });

});



}

Notice that I am calling the gapi.client.igardenendpoints direct in the body of Controler, is that correct? But it is not working.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.