Home > Net >  Angular2 reference signalr. Js problems and couldn't find a solution
Angular2 reference signalr. Js problems and couldn't find a solution

Time:09-24

with.net 2.0 and angular2 core + reference signalr. Js problem, 2 days, baidu, Google, bing has no answer, group also nobody,
Hereby to master taught this, thank you thank you
presents the code in the


browser console error


now, there are several suspects:
1. I is reference to the signalr here? (download from n have PM to node_modules)
2. Whether the signalr I write right?
3. Why the browser request by more than a '//negotiate? I don't in presents this obviously?

The feeling, really have urgent crazy!


other families and reference code: the server code

CodePudding user response:

Try to jointly study the app. MapSignalR

CodePudding user response:

Elder brother I dug grave, I also in studying this problem, your qq I was speechless, with hair, asked me how many 416532793 elder brother see give a news

CodePudding user response:

I have SignaRI PDF, you can reference

CodePudding user response:

https://medium.com/@rukshandangalla/how-to-notify-your-angular-5-app-using-signalr-5e5aea2030b2


The import {Component, OnInit} from '@ presents/core;
The import {HubConnection} from '@ aspnet/signalr - client;

The import {Message} from 'primeng/API;

@ Component ({
The selector: 'app - root',
TemplateUrl: './app.com ponent. HTML ',
StyleUrls: ['./app.com ponent. CSS ']
})
Export class AppComponent implements the OnInit {

Private _hubConnection: HubConnection;
MSGS: Message []=[];

The constructor () {}

NgOnInit () : void {
Enclosing _hubConnection=new HubConnection (' http://localhost:1874/notify ');
Enclosing _hubConnection
The start ()
Then (()=& gt; The console. The log (' Connection started! '))
The catch (err=& gt; The console. The log (' Error while establishing the connection: ('));

This. _hubConnection. On (' BroadcastMessage '(type: string, content: string)=& gt; {
Enclosing MSGS. Push ({severity: type, the summary: payload});
});
}
}

CodePudding user response:

Brother have a solution

CodePudding user response:

Has been solved, cross-domain problem
  • Related