AngularJS dataservice using breezejs doesn't resolve promise

I am trying to configure a data service in my Angular application using breezeJS. After I keep my promise, I can’t get it. Then register your controller. I am returning data from my database through a breeze in my data service. I could just convey the promise of the breeze, but I want to use $ q.all to find out when all my data was found.

In my controller

ProApp.controller ('caseInfoController', function caseInfoController ($ scope, $ log, $ timeout, caseDataService) {

    /***initialize data ***/
   // initializeApp();


    ATPinitializeApp();


    function ATPinitializeApp() {

        $scope.MyStateList=   caseDataService.getAllStates()
         .then(function assignStates(data) {
             $log.info("THIS THEN WILL NOT FIRE");               
         });

    }

`

The above does not work when the promise of the data service is fulfilled.

ProApp.factory('caseDataService', function ($log, $q)
{

breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);


var servicename = "http://localhost:60882/breeze/SPLBreeze";
var manager = new breeze.EntityManager(servicename);

var caseDataService =
{
   getAllStates: getAllStates,

};

return caseDataService;

/*** implementation details ***/


function getAllStates()
{

  var myStatePromise = $q.defer();

  var query = breeze.EntityQuery
      .from("state");

  manager.executeQuery(query)
    .then(function (data) {
        $timeout(function () { myStatePromise.resolve(data); }, 200);;
    });

  return myStatePromise.promise;
};

. 100%, $q promises. , $q.all, , promises , . , , Angular, , .

+1
2

Angular $q. , .

, fooobar.com/questions/1520873/..., , Q.js $q.

+4

, , , .

  /***initialize data ***/
    . . .
    function ATPinitializeApp() {

        $scope.MyStateList=   caseDataService.getAllStates()
         .then(function assignStates(data) {
             $log.info("THIS THEN WILL NOT FIRE");  
             return data; // If you don´t return anything nothing will be added to the scope.
         });

    }

$timeout getAllStates, angular promises ( $rootScope. $evalAsync)

function getAllStates()
{
. . .

  manager.executeQuery(query)
    .then(function (data) {
       // I believe the $timeout that was in this function is not necessary
       myStatePromise.resolve(data);
    });

  return myStatePromis

e.promise;

}

, .

,

0

All Articles