Skip to content

Commit d67c977

Browse files
Cibele MartinsCibele Martins
authored andcommitted
🚧 feat: Injecting service
1 parent 29cd5ef commit d67c977

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
import { Component, EventEmitter, Input, Output } from '@angular/core';
2+
import { LoggingService } from '../logging.service';
23

34
@Component({
45
selector: 'app-account',
56
templateUrl: './account.component.html',
6-
styleUrls: ['./account.component.css']
7+
styleUrls: ['./account.component.css'],
8+
providers: [LoggingService]
79
})
810
export class AccountComponent {
911
@Input() account: {name: string, status: string};
1012
@Input() id: number;
1113
@Output() statusChanged = new EventEmitter<{id: number, newStatus: string}>();
1214

15+
constructor(private logging: LoggingService) {
16+
17+
}
18+
1319

1420
onSetTo(status: string) {
1521
this.statusChanged.emit({id: this.id, newStatus: status});
16-
console.log('A server status changed, new status: ' + status);
22+
23+
this.logging.changeStatus(status)
1724
}
25+
1826
}
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import { Component, EventEmitter, Output } from '@angular/core';
2+
import { LoggingService } from '../logging.service';
23

34
@Component({
45
selector: 'app-new-account',
56
templateUrl: './new-account.component.html',
6-
styleUrls: ['./new-account.component.css']
7+
styleUrls: ['./new-account.component.css'],
8+
providers: [LoggingService]
79
})
810
export class NewAccountComponent {
911
@Output() accountAdded = new EventEmitter<{name: string, status: string}>();
1012

13+
constructor (private logging: LoggingService) {
14+
15+
}
16+
1117
onCreateAccount(accountName: string, accountStatus: string) {
1218
this.accountAdded.emit({
1319
name: accountName,
1420
status: accountStatus
1521
});
16-
console.log('A server status changed, new status: ' + accountStatus);
22+
23+
this.logging.changeStatus(accountStatus)
1724
}
1825
}

0 commit comments

Comments
 (0)