File tree Expand file tree Collapse file tree 6 files changed +14
-18
lines changed
src/AspNetCoreAngular2/wwwroot/app Expand file tree Collapse file tree 6 files changed +14
-18
lines changed Original file line number Diff line number Diff line change 1
1
# Angular 2, ASP.NET Core Template With SignalR 3
2
2
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
4
4
5
5
Just clone this repo and run <pre >npm install</pre >
6
6
After this you can type <pre >dnx web</pre > to start the ASP.NET Server
Original file line number Diff line number Diff line change 1
- import { Component , OnInit } from 'angular2/core' ;
1
+ import { Component } from 'angular2/core' ;
2
2
3
3
@Component ( {
4
4
selector : 'about' ,
5
- templateUrl : 'app/about/about.component.html'
5
+ templateUrl : 'app/about/about.component.html' ,
6
6
} )
7
7
8
- export class AboutComponent implements OnInit {
8
+ export class AboutComponent {
9
9
10
- public message : string ;
11
10
12
- constructor ( ) { }
13
-
14
- ngOnInit ( ) {
15
- //...
16
- }
17
11
}
Original file line number Diff line number Diff line change 7
7
< span class ="icon-bar "> </ span >
8
8
< span class ="icon-bar "> </ span >
9
9
</ button >
10
- < a class ="navbar-brand " href ="index.html "> Angular2 Demo by Offering.Solutions © 2016</ a >
10
+ < a class ="navbar-brand " href ="/ "> Angular2 Demo by Offering.Solutions © 2016</ a >
11
11
</ div >
12
12
<!-- /.navbar-header -->
13
13
Original file line number Diff line number Diff line change 1
1
import { Component } from 'angular2/core' ;
2
- import { RouteConfig , ROUTER_DIRECTIVES , ROUTER_PROVIDERS } from 'angular2/router' ;
2
+ import { RouteConfig , ROUTER_DIRECTIVES } from 'angular2/router' ;
3
3
import { DashboardComponent } from './dashboard/dashboard.component' ;
4
4
import { AboutComponent } from './about/about.component' ;
5
5
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ChatMessage } from '../models/ChatMessage';
6
6
@Component ( {
7
7
selector : 'chat-component' ,
8
8
templateUrl : 'app/chat/chat.component.html' ,
9
- directives : [ CORE_DIRECTIVES ]
9
+ directives : [ CORE_DIRECTIVES ] ,
10
10
} )
11
11
12
12
@@ -24,8 +24,10 @@ export class ChatComponent {
24
24
}
25
25
26
26
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
+ }
29
31
}
30
32
31
33
private subscribeToEvents ( ) : void {
@@ -34,7 +36,7 @@ export class ChatComponent {
34
36
} ) ;
35
37
36
38
this . _signalRService . messageReceived . subscribe ( ( message : ChatMessage ) => {
37
- this . currentMessage = new ChatMessage ( "" , null ) ;
39
+ this . currentMessage = new ChatMessage ( '' , null ) ;
38
40
this . allMessages . push ( new ChatMessage ( message . Message , message . Sent . toString ( ) ) ) ;
39
41
} ) ;
40
42
}
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ export class FoodComponent implements OnInit {
22
22
}
23
23
24
24
public ngOnInit ( ) {
25
- this . getAllFood ( ) ;
26
25
this . subscribeToEvents ( ) ;
27
26
}
28
27
@@ -56,7 +55,7 @@ export class FoodComponent implements OnInit {
56
55
} , error => {
57
56
console . log ( error ) ;
58
57
} , ( ) => {
59
- console . log ( " Deleted complete" ) ;
58
+ console . log ( ' Deleted complete' ) ;
60
59
} ) ;
61
60
}
62
61
@@ -75,6 +74,7 @@ export class FoodComponent implements OnInit {
75
74
private subscribeToEvents ( ) :void {
76
75
this . _signalRService . connectionEstablished . subscribe ( ( ) => {
77
76
this . canAddFood = true ;
77
+ this . getAllFood ( ) ;
78
78
} ) ;
79
79
80
80
this . _signalRService . foodchanged . subscribe ( ( ) => {
You can’t perform that action at this time.
0 commit comments