How do I Print a Parse.Query result in a View?

Asked

Viewed 39 times

0

I have the following situation, in View:

{{nomeCraque}}

and in the Angular:

$scope.nomeCraque = {};
var EscalacaoObject = Parse.Object.extend("Escalacao");
var query = new Parse.Query(EscalacaoObject);
query.find({   
          success: function(results) {
          // Successfully retrieved the object.

          for (var i = 0; i < results.length; i++) {
            var object = results[i];
            $scope.nomeCraque = object.get("nomeCraque");
          }

        },
        error: function(error) {
        alert("Error: " + error.code + " " + error.message);
        }
  })              

In this way $scope.nomeCraque prints {} in View, how do I print on Viewthe correct result that the Query is returning?

  • console.log(object.get("nomeCraque")); shows what?

  • Shows the correct data returned by Parse.Query.

  • $Scope.nameCrac = { name: 'startName' }; in the view {{nameCrac.name}}, then just assign the value by opening $Scope

  • Felipe, good morning to you! sorry but I didn’t understand when you say: "assign the value by opening $Scope", how should I assign the value returned from Parse.Query to the variable $Scope.fieldName ?

  • $Scope.nameCrac = { name: Object.get("nameCrac"); }

  • may solve your problem

  • Felipe, I don’t know if I did something wrong, it follows an excerpt from the ... Start with $Scope.nameCrac = { name: 'startName' }; ... I did value assignment as $Scope.nameCrac = { name: Object.get("startName") } ; Because the way you wrote it, $Scope.fieldName = { name: Object.get("racName"); } causes syntax error when saving code: "Uncaught Syntaxerror: Unexpected token ;" But, unfortunately it hasn’t worked out yet, because in the view it looks like this: {"name":""} DETAIL, in the console.log it looks like this: Object {name: testname} Have any idea why?

  • @Ita in the assignment you cannot close the query with a semicolon, leave with nothing or end with a comma

  • OK Felipe, I understand, but regardless of this detail, the problem persists and in the view I can’t get the result returned by Parse.Query, is that there is missing some more procedure to be done?

Show 4 more comments

1 answer

0

Felipe, thank you so much for your help so far, in this final part I discovered what was missing, follows below the treatment I did in my angular code: $Scope.nameCrac = { name: Object.get("nameCrac") }; $Scope. $apply(); NOW IT IS WORKING AS I WANTED! THAT IS, THE RESULT OF PARSE.QUERY IS BEING DISPLAYED IN THE VIEW! Thank you all for your support!

Browser other questions tagged

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