0

I'm using angular11 with jquery, I added a script as below:

let node = document.createElement('script');
let url=this.GlobalServ.BasicUrl+'signalr/hubs';
node.src = url;
node.id = 'signalr'
 document.getElementsByTagName('head')[0].appendChild(node);

When I'm trying to use the content of Signalr/hubs file (In my case: "cloudsferWebHub") It doesn't work:

$.connection.hub.qs = { 'migration': this.contentData.Id };
var agents = $.connection.cloudsferWebHub; //cloudsferWebHub is undefined

noa c
  • 1
  • It's not really a good idea to use jQuery together with Angular. To use signalR in Angular, you can create a service that simply imports @aspnet/signalr (like import * as signalR from '@aspnet/signalr') – MikeOne Aug 18 '21 at 08:54
  • The @aspnet/signalr package is used for .Net Core. And Im using .Net Framework I installed the signalr package: npm install signalr. – noa c Aug 19 '21 at 07:04

1 Answers1

0

It may have to do with ensuring that your order is correct in your angular.json file. Jquery must be loaded before signalR. See this stackflow for a much more detailed answer.

Frank M
  • 1,379
  • 9
  • 18