AngularJS with SignalR not working
-
18-10-2022 - |
Frage
My js code for Angular js won't work. In jQuery it works.
In Angular I always get the connection state 4
for disconnect.
The jQuery code works fine.
AngularJS:
vvApp.value("$", $);
vvApp.service("signalRSvc", function ($, $rootScope) {
var proxy = null;
var initialize = function () {
connection = $.hubConnection();
this.proxy = connection.createHubProxy("helloWorldHub");
connection.start();
this.proxy.on('sendGreeting', function (message) {
$rootScope.$emit("sendGreeting", message);
});
};
var sendRequest = function () {
this.proxy.invoke('greatAll');
};
return {
initialize: initialize,
sendRequest: sendRequest
};
});
function SignalRAngularCtrl($scope, signalRSvc, $rootScope) {
$scope.greetAll = function () {
signalRSvc.sendRequest();
}
signalRSvc.initialize();
}
Keine korrekte Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow