Last active
November 16, 2017 07:18
-
-
Save Ibro/a0ba0540f0be3db2b3a28112e47dc095 to your computer and use it in GitHub Desktop.
ASP.NET Core SignalR chat with Angular 5 - https://codingblast.com/asp-net-core-signalr-chat-angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { HubConnection } from '@aspnet/signalr-client'; | |
@Component({ | |
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'); | |
this.hubConnection | |
.start() | |
.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