Angular11 - SignalR $.hubConnection() is not a function

Viewed 128

I am using Angular 11.0.4, and trying to create connection with server from angular client. But getting this error:

ERROR TypeError: jquery__WEBPACK_IMPORTED_MODULE_5__.hubConnection is not a function

I have installed jQuery ("jquery": "^3.6.0") , and SignalR ("signalr": "^2.4.3")

I checked the similar questions here, here and here, but no luck.

Inside angular.json, I placed these lines in scripts array.

 "scripts": [
              ...
   
              "node_modules/jquery/dist/jquery.js", 

              "node_modules/signalr/jquery.signalR.js" 
            ]

Angular code:

var connection = $.hubConnection();
var hub1Proxy = connection.createHubProxy('hub1');
hub1Proxy.on('mymethod', function(name, message) {
    console.log(name + ' ' + message);
});

All these changes could not help to get rid of above error.

Server Side Hub is defined in .Net Framework 4.7.2 MVC Project.

Can anybody suggest, what is missing here?

0 Answers
Related