Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS dataservice using breezejs it not resolving the promise
    primarykey
    data
    text
    <p>I'm trying to setup a data service in my Angular application that is using breezeJS. After I resolve my promise I can't get the .then to file in my controller. I am getting data back from my database via breeze in my data service. I could just pass back the breeze promise but I want to be able to use $q.all to know when all my data has been found.</p> <p>In my controller`</p> <p>ProApp.controller('caseInfoController', function caseInfoController($scope, $log, $timeout, caseDataService) {</p> <pre><code> /***initialize data ***/ // initializeApp(); ATPinitializeApp(); function ATPinitializeApp() { $scope.MyStateList= caseDataService.getAllStates() .then(function assignStates(data) { $log.info("THIS THEN WILL NOT FIRE"); }); } </code></pre> <p>`</p> <p>The above then will not fire when the promise from the data service is fulfilled.</p> <pre><code>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; }; </code></pre> <p>Any help would be greatly appreciated. I'm not 100% sure if I have the $q promises set up correctly. Eventually I would like to use a $q.all to determine when an array of various promises have been resolved to so I can update a message to the user. I've been reading that I need to use a timeout to get angular to realize that a change has happened in the next event loop. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload