I am integrating a web service client into an angular service. This specific client sends out events for certain updates like this:
app.service('AngularClient', function () {
this.info = null
this.login = function () {
client.login(loginInfo).then(function (loggedClient) {
loggedClient.on('newInfo', function (info) {
this.info = info
})
})
}
})
A controller utilizes this service and connects it to its $scope
:
app.controller('Ctrl', function (AngularClient, $scope) {
$scope.client = AngularClient
})
However, whenever the 'newInfo'
event is triggered, angular does not automatically initiate a digest
cycle, preventing me from controlling when the info
is updated in the UI. How can I ensure that this happens every time in an angular way?