Thank you so much for trying out the PubNub AngularJS API! I will try to provide some help. There is a little difference between the PubNub JS API and the AngularJS PubNub API in this case.
Background
Behind the scenes, the PubNub JS API method history()returns instantly, and invokes a callback when this story page is retrieved.
API AngularJS, ,
- $rootScope.$broadcast()
.
API AngularJS " ",
"ngHistory" . 2
: , ,
.
1) . codepen (http://codepen.io/sunnygleason/pen/afqmh). API PubNub AngularJS "escape-hatch", JS API , jsapi. PubNub.jsapi.history({channel:theChannel,limit:theLimit,callback:theCallback}). , , , $rootScope, $rootScope.$apply() $scope.$apply(), , , $scope , .
2) . codepen (http://codepen.io/sunnygleason/pen/JIsek). , ngHistoryQ() 1.2.0-beta.4 API PubNub AngularJS. , :
PubNub.ngHistoryQ({channel:theChannel,limit:theLimit}).then(function(payload) {
payload[0].forEach(function(message) {
$scope.messages.push(message);
}
});
SDK AngularJS, "bower install pubnub- angular".
. # 2, :
var historyPromise = PubNub.ngHistoryQ({channel:theChannel,limit:theLimit});
showSpinner();
historyPromise.then(function(payload) {
hideSpinner();
});
? , . .