feat(devtools): add a demo pipe with ngOnDestroy

This commit is contained in:
mgechev 2020-08-26 21:22:40 +03:00 committed by Minko Gechev
parent 199745fd6c
commit ddeacebd7b
3 changed files with 19 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import { TodoComponent } from './todos/todo/todo.component';
import { TodosFilter } from './todos/todos.pipe';
import { TooltipDirective } from './todos/todo/tooltip.directive';
import { CommonModule } from '@angular/common';
import { SamplePipe } from './sample.pipe';
@NgModule({
imports: [
@ -17,7 +18,7 @@ import { CommonModule } from '@angular/common';
},
]),
],
declarations: [TodosComponent, TodoComponent, TodosFilter, TooltipDirective],
declarations: [SamplePipe, TodosComponent, TodoComponent, TodosFilter, TooltipDirective],
exports: [TodosComponent],
})
export class HomeModule {}

View file

@ -0,0 +1,15 @@
import { Pipe, OnDestroy, PipeTransform } from '@angular/core';
@Pipe({
name: 'sample',
pure: false,
})
export class SamplePipe implements PipeTransform, OnDestroy {
transform(val: any): void {
return val;
}
ngOnDestroy(): void {
console.log('Destroying');
}
}

View file

@ -2,6 +2,8 @@
<a [routerLink]="">Home</a>
<a [routerLink]="">Home</a>
<p>{{ 'Sample text processed by a pipe' | sample }}</p>
<section class="todoapp">
<header class="header">
<h1>todos</h1>