Reputation: 28659
I am under the impression that binding to a promise in my html
<ul ng-repeat='i in items'>
<li>{{i}}</li>
</ul>
(where $scope.items
is the promise), that when the promise is resolved, the scope will automatically update.
var _deferred = $q.defer();
$scope.items = _deferred.promise;
$scope.setItems = function() {
_deferred.resolve([
'Here',
'There',
'Everywhere'
]);
};
When I call setItems()
, the promise is resolved, but my html doesn't update.
What am I doing wrong?
Upvotes: 0
Views: 310
Reputation: 193261
The way you are setting items is not correct. $scope.items
should not be a Promise object, but you should use Promise then
methods to set items:
_deferred.promise.then(function(items) {
$scope.items = items;
});
Upvotes: 3