Initialize some user parameters using angularjs and Google Cloud Endpoints

2

I'm trying to initialize some user parameters using AngularJs and google cloud endpoints. Through an endpoint getProfile, I need to get the user information like photo, description, age to display on the screen. I can make a call of this type using a form and a button for example, which I am not able to do and make that call before the page is loaded, so when it is loaded I already have the screen display information.

This is more or less 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'm calling the gapi.client.igardenendpoints directive in the Controller's body, is this correct? But it is not working.

    
asked by anonymous 10.09.2016 / 05:27

0 answers