Skip to content

Instantly share code, notes, and snippets.



Last active Nov 16, 2017
What would you like to do?
ASP.NET Core SignalR chat with Angular 5 -
import { Component, OnInit } from '@angular/core';
import { HubConnection } from '@aspnet/signalr-client';
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
export class AppComponent implements OnInit {
private hubConnection: HubConnection;
nick = '';
message = '';
messages: string[] = [];
ngOnInit() {
this.nick = window.prompt('Your name:', 'John');
this.hubConnection = new HubConnection('http://localhost:5000/chat');
.then(() => console.log('Connection started!'))
.catch(err => console.log('Error while establishing connection :('));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.