File tree Expand file tree Collapse file tree 5 files changed +23
-6
lines changed Expand file tree Collapse file tree 5 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1+ // injectable
2+ import { Injectable } from "@angular/core" ;
3+
4+ // other service
5+ import { LoggingService } from "./logging.service" ;
6+
7+ @Injectable ( )
8+
19export class AccountService {
210
311 accounts = [
@@ -15,11 +23,17 @@ export class AccountService {
1523 }
1624 ] ;
1725
26+ constructor ( private logging : LoggingService ) {
27+
28+ }
29+
1830 onAccountAdded ( name : string , status : string ) {
1931 this . accounts . push ( { name : name , status : status } ) ;
32+ this . logging . changeStatus ( status )
2033 }
2134
2235 onStatusChanged ( id : number , newStatus : string ) {
2336 this . accounts [ id ] . status = newStatus ;
37+ this . logging . changeStatus ( newStatus )
2438 }
2539}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { AccountService } from '../account.service';
66 selector : 'app-account' ,
77 templateUrl : './account.component.html' ,
88 styleUrls : [ './account.component.css' ] ,
9- providers : [ LoggingService ]
9+ // providers: [LoggingService]
1010} )
1111export class AccountComponent {
1212 @Input ( ) account : { name : string , status : string } ;
@@ -18,7 +18,7 @@ export class AccountComponent {
1818
1919 onSetTo ( status : string ) {
2020 this . accountService . onStatusChanged ( this . id , status )
21- this . logging . changeStatus ( status )
21+ // this.logging.changeStatus(status)
2222 }
2323
2424}
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { AccountService } from './account.service';
55 selector : 'app-root' ,
66 templateUrl : './app.component.html' ,
77 styleUrls : [ './app.component.css' ] ,
8- providers : [ AccountService ]
98} )
109export class AppComponent {
1110
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ import { AppComponent } from './app.component';
77import { AccountComponent } from './account/account.component' ;
88import { NewAccountComponent } from './new-account/new-account.component' ;
99
10+ // servic es
11+ import { AccountService } from './account.service' ;
12+ import { LoggingService } from './logging.service' ;
13+
1014@NgModule ( {
1115 declarations : [
1216 AppComponent ,
@@ -17,7 +21,7 @@ import { NewAccountComponent } from './new-account/new-account.component';
1721 BrowserModule ,
1822 FormsModule ,
1923 ] ,
20- providers : [ ] ,
24+ providers : [ AccountService , LoggingService ] ,
2125 bootstrap : [ AppComponent ]
2226} )
2327export class AppModule { }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { AccountService } from '../account.service';
66 selector : 'app-new-account' ,
77 templateUrl : './new-account.component.html' ,
88 styleUrls : [ './new-account.component.css' ] ,
9- providers : [ LoggingService ]
9+ // providers: [LoggingService]
1010} )
1111export class NewAccountComponent {
1212
@@ -22,6 +22,6 @@ export class NewAccountComponent {
2222
2323 this . accountService . onAccountAdded ( accountName , accountStatus )
2424
25- this . logging . changeStatus ( accountStatus )
25+ // this.logging.changeStatus(accountStatus)
2626 }
2727}
You can’t perform that action at this time.
0 commit comments