-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loose access to $scope #19
Comments
ng-websockets events doesn't trigger a angular $digest. (Which I really think it should, btw.). Anyway, all you have to do is trigger it yourself.
This can potentially trigger an error if angular is already in a digesting state. One easy way to waif for the previous digest to complete is to use $timeout. (You have to inject it):
(Using $timeout without a delay-value will run a function immediately or as soon as the current digest finishes). |
I am new to AngularJS and this one was driving me nuts, I even looked everything there is to know about scopes and inheritance. The solution of @kumorig works, but is missing the '$': $scope.message = message;
$scope.$apply(); It really is a valid workaround, but it kind of "de-angularizes" the main purpose of websockets:
Is there another way of achieving this with ng-websocket or something that we are missing? |
Fix this issue: wilk#19
Fix this issue: wilk#19 Inspired by this library: https://github.com/AngularClass/angular-websocket/blob/master/angular-websocket.js#L90
Hi
I have a websocket connection open and data is being sent from the server. However I cannot apply this data to the controller $scope?
angular.module('bedappApp').controller('MainCtrl', function ($scope, $websocket) {
var ws = $websocket.$new({
url: 'ws://localhost:8080'
});
});
The watch never updates, also a simple two way binding on the html page does not update.
The console does show the data being received and printed.
Object {0: "1.308500E-01", type: "Potential", key: "0", value: "1.308500E-01", source: "temp"} scripts.a3a83e70.js:1
Object {type: "board", key: "AmbientTemperature", value: "2.238280E+01", AmbientTemperature: "2.238280E+01", source: "temp"} scripts.a3a83e70.js:1
Object {0: "2.453350E+01", type: "Temperature", key: "0", value: "2.453350E+01", source: "temp"} scripts.a3a83e70.js:1
Object {0: "8.703000E-02", type: "Potential", key: "0", value: "8.703000E-02", source: "temp"} scripts.a3a83e70.js:1
Object {type: "board", key: "AmbientTemperature", value: "2.233590E+01", AmbientTemperature: "2.233590E+01", source: "temp"} scripts.a3a83e70.js:1
Object {0: "2.351650E+01", type: "Temperature", key: "0", value: "2.351650E+01", source: "temp"} scripts.a3a83e70.js:1
Object {0: "4.774000E-02", type: "Potential", key: "0", value: "4.774000E-02", source: "temp"}
I am at a loss as to what is going on ? isolate scope ?
Regards
Gary
The text was updated successfully, but these errors were encountered: