mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
feat(devtools): add a demo pipe with ngOnDestroy
This commit is contained in:
parent
199745fd6c
commit
ddeacebd7b
3 changed files with 19 additions and 1 deletions
|
|
@ -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 {}
|
||||
|
|
|
|||
15
src/app/demo-app/todo/home/sample.pipe.ts
Normal file
15
src/app/demo-app/todo/home/sample.pipe.ts
Normal 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');
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue