Skip to content

Commit c21ddcd

Browse files
PatrickPatrick
authored andcommitted
feature(): start implementing decorator
1 parent 7ba8b99 commit c21ddcd

10 files changed

+106
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
import { DecoratorComponent } from './decorator/decorator.component';
5+
6+
const routes: Routes = [{ path: '', component: DecoratorComponent }];
7+
8+
@NgModule({
9+
imports: [RouterModule.forChild(routes)],
10+
exports: [RouterModule]
11+
})
12+
export class DecoratorRoutingModule { }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
4+
import { DecoratorRoutingModule } from './decorator-routing.module';
5+
import { DecoratorComponent } from './decorator/decorator.component';
6+
7+
8+
@NgModule({
9+
declarations: [DecoratorComponent],
10+
imports: [
11+
CommonModule,
12+
DecoratorRoutingModule
13+
]
14+
})
15+
export class DecoratorModule { }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>decorator works!</p>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { DecoratorComponent } from './decorator.component';
4+
5+
describe('DecoratorComponent', () => {
6+
let component: DecoratorComponent;
7+
let fixture: ComponentFixture<DecoratorComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ DecoratorComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(DecoratorComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-decorator',
5+
templateUrl: './decorator.component.html',
6+
styleUrls: ['./decorator.component.scss']
7+
})
8+
export class DecoratorComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit(): void {
13+
}
14+
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {INotifier} from "./notifier.model";
2+
3+
export class EmailNotifier implements INotifier {
4+
protected notifier: INotifier;
5+
6+
constructor(notifier: INotifier) {
7+
this.notifier = notifier;
8+
}
9+
public send(message: string): string {
10+
return this.notifier.send(message);
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface INotifier {
2+
send(message: string): string;
3+
}
4+
5+
export class Notifier implements INotifier {
6+
public send(message: string): string {
7+
console.log(message);
8+
return message;
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {INotifier} from "./notifier.model";
2+
3+
export class SMSNotifier implements INotifier {
4+
protected notifier: INotifier;
5+
6+
constructor(notifier: INotifier) {
7+
this.notifier = notifier;
8+
}
9+
public send(message: string): string {
10+
return this.notifier.send(message);
11+
}
12+
}

src/app/app-routing.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const routes: Routes = [
3636
{
3737
path: '',
3838
redirectTo: '/home', pathMatch: 'full'
39+
},
40+
{
41+
path: 'decorator',
42+
loadChildren: () => import('./09. Decorator/decorator.module').then(m => m.DecoratorModule)
3943
}
4044

4145
];

0 commit comments

Comments
 (0)