I have a service that is making a call to UPS api and returning a promise. The request and return is taking an average around 3-4 seconds. After the return I am trying to set a scope for $scope.printOrder. It doesn't seem that Angular is picking up on such a long wait time. What are my options on making Angular wait for the request, or is it and I am doing something else wrong.
Thanks
Service
ordersApp.factory('upsPrint', function ($http, $q)
{
return {
upsPrint: function (order)
{
var deferred = $q.defer();
$http.post('orders/upsPrint',{order: order}).success(function(data)
{
deferred.resolve(data);
});
return deferred.promise;
}
};
});
Controller
$scope.printOrder = function (order)
{
$scope.printingOrder = upsPrint.upsPrint(order);
$scope.printingOrder.then(function(upsPrint){
$scope.printedOrder = upsPrint.printedOrder;
console.log($scope.printedOrder);
});
};
View
<div ng-controller="ordersCtrl">
<div ng-model="printedOrder">
{{printedOrder}}
</div>
</div>