beevelop / ng-stomp

:bookmark_tabs: STOMP for AngularJS
http://beevelop.github.io/stomp-ui/
MIT License
44 stars 43 forks source link

ng-bind has not updated the view #1

Closed chaoyangnz closed 9 years ago

chaoyangnz commented 9 years ago

var subscription = $stomp.subscribe('/queue/' + user.id + '/interviews/1', function (payload, headers, response) { console.log(headers) console.log(response) console.log(payload)

$scope.ss = 'sf'  // here !!!!!

}, {});

I update the variables in the callback, but the view has no update to reflect the change.

kurbatov commented 9 years ago

Try to add

$scope.$apply();

at the end of the callback.

chaoyangnz commented 9 years ago

@kurbatov yes, I actually did that. But is it a bug of ng-stomp or not?

kurbatov commented 9 years ago

I guess it is not a bug. This behavior gives more fine-grained control over updating the view.

beevelop commented 9 years ago

@richdyang IMHO a library should not explicitly apply the scope as this might lead to undesired side effects.