angular-service-utilities
angular-service-utilities copied to clipboard
Attached promise property not resolved until a refresh is done (using ui-router)
trafficstars
I am wondering whether ui-router and this lib play well together. It seems my $scope property is not resolved when the controller is first instantiated. I need to refresh the page to see the promised JSON in the view. What am I doing wrong?
Service:
app.factory('TheCart', function($q,CartResource,$serviceScope){
var $scope = $serviceScope();
var deferredCart = $scope.$defer('theCart');
CartResource.retrieveCart(function(cart){
deferredCart.resolve(cart[0]);
});
return $scope;
});
Controller:
app.controller('CartCtrl', function (TheCart,$scope)
{
TheCart.$attachProperty('theCart', $scope, 'theCart');
}
View:
<div>
{{ theCart | json }}
</div>