Losing $scope variable using Parse

Today I started studying Angular using Parse, and I'm having an issue. When I create a Query to have all data of a table from Parse all goes good, but when I create a $scope.variable for send that array to the view, it's not having anything. I think I'm losing the variable.

Here is the code:

angular.module('starter', ['ionic'])

.controller('listadoFiestas',function($scope, $state) { 


      var lista;
      Parse.initialize("xxx", "xxx");
      var Fiestas = Parse.Object.extend("Fiestas");
      var fiesta = new Parse.Query(Fiestas);

      fiesta.find({
        success: function(results) {
            for(var i=0; i<results.length;i++) {
              lista = (
                  {
                  'nombre': results[i].attributes.nombre,
                  'descripcion': results[i].attributes.descripcion
                  }
                );
            }
            $scope.lista = lista;
        },
        error: function() {
          console.log("error");
        }
      });

      $scope.variable = lista;



});

Maybe someone can help me, thank you!

Answers


I think you want to do this:

$scope.variable = $scope.lista

to have everything from the lista variable also in the $scope.variable.

You should be able to access $scope.lista already in the view, because it is bound to your scope, so you don't need to save it to a separate variable on the scope.

Update:

You should push results to the variable lista which should also be initialised like this:

var lista = [];

and then do:

lista.push({ 'nombre': results[i].attributes.nombre,
             'descripcion': results[i].attributes.descripcion});

Need Your Help

How to get Enum value statically?

c# json asp.net-mvc enums json.net

I want to get the EnumMember's Value statically. It works if I pass fill out my model, as shown below.

How to reverse engineer C library?

c dll reverse-engineering disassembly

Suppose that I have a dynamic library (.so) on Linux. I also have an existing application that uses the library. The library is stripped. I would like to produce some (approximate) header file ...