Skip to content

Commit 5f58bee

Browse files
small refactoring
1 parent fcd2c50 commit 5f58bee

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Angular 2, ASP.NET Core Template With SignalR 3
22

3-
## In this repo we will try a first look at SignalR 3, ASP.NET CORE and Angular 2
3+
## In this repo we will try a first look at SignalR 3, ASP.NET Core and Angular 2
44

55
Just clone this repo and run <pre>npm install</pre>
66
After this you can type <pre>dnx web</pre> to start the ASP.NET Server
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import {Component, OnInit} from 'angular2/core';
1+
import {Component} from 'angular2/core';
22

33
@Component({
44
selector: 'about',
5-
templateUrl: 'app/about/about.component.html'
5+
templateUrl: 'app/about/about.component.html',
66
})
77

8-
export class AboutComponent implements OnInit {
8+
export class AboutComponent {
99

10-
public message: string;
1110

12-
constructor() { }
13-
14-
ngOnInit() {
15-
//...
16-
}
1711
}

src/AspNetCoreAngular2/wwwroot/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<span class="icon-bar"></span>
88
<span class="icon-bar"></span>
99
</button>
10-
<a class="navbar-brand" href="index.html">Angular2 Demo by Offering.Solutions &copy; 2016</a>
10+
<a class="navbar-brand" href="/">Angular2 Demo by Offering.Solutions &copy; 2016</a>
1111
</div>
1212
<!-- /.navbar-header -->
1313

src/AspNetCoreAngular2/wwwroot/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from 'angular2/core';
2-
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router';
2+
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
33
import {DashboardComponent} from './dashboard/dashboard.component';
44
import {AboutComponent} from './about/about.component';
55

src/AspNetCoreAngular2/wwwroot/app/chat/chatcomponent.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ChatMessage } from '../models/ChatMessage';
66
@Component({
77
selector: 'chat-component',
88
templateUrl: 'app/chat/chat.component.html',
9-
directives: [CORE_DIRECTIVES]
9+
directives: [CORE_DIRECTIVES],
1010
})
1111

1212

@@ -24,8 +24,10 @@ export class ChatComponent {
2424
}
2525

2626
public sendMessage() {
27-
this.currentMessage.Sent = new Date();
28-
this._signalRService.sendChatMessage(this.currentMessage);
27+
if (this.canSendMessage) {
28+
this.currentMessage.Sent = new Date();
29+
this._signalRService.sendChatMessage(this.currentMessage);
30+
}
2931
}
3032

3133
private subscribeToEvents(): void {
@@ -34,7 +36,7 @@ export class ChatComponent {
3436
});
3537

3638
this._signalRService.messageReceived.subscribe((message: ChatMessage) => {
37-
this.currentMessage = new ChatMessage("", null);
39+
this.currentMessage = new ChatMessage('', null);
3840
this.allMessages.push(new ChatMessage(message.Message, message.Sent.toString()));
3941
});
4042
}

src/AspNetCoreAngular2/wwwroot/app/food/foodcomponent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class FoodComponent implements OnInit {
2222
}
2323

2424
public ngOnInit() {
25-
this.getAllFood();
2625
this.subscribeToEvents();
2726
}
2827

@@ -56,7 +55,7 @@ export class FoodComponent implements OnInit {
5655
}, error => {
5756
console.log(error);
5857
}, () => {
59-
console.log("Deleted complete");
58+
console.log('Deleted complete');
6059
});
6160
}
6261

@@ -75,6 +74,7 @@ export class FoodComponent implements OnInit {
7574
private subscribeToEvents():void{
7675
this._signalRService.connectionEstablished.subscribe(() => {
7776
this.canAddFood = true;
77+
this.getAllFood();
7878
});
7979

8080
this._signalRService.foodchanged.subscribe(() => {

0 commit comments

Comments
 (0)