File tree Expand file tree Collapse file tree
apps/angular/8-pure-pipe/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Component } from '@angular/core' ;
1+ import { Component , Pipe , PipeTransform } from '@angular/core' ;
2+
3+ @Pipe ( {
4+ name : 'heavyComputation' ,
5+ } )
6+ export class HeavyComputationPipe implements PipeTransform {
7+ transform ( name : string , index : number ) {
8+ // very heavy computation
9+ return `${ name } - ${ index } ` ;
10+ }
11+ }
212
313@Component ( {
414 selector : 'app-root' ,
15+ imports : [ HeavyComputationPipe ] ,
516 template : `
617 @for (person of persons; track person) {
7- {{ heavyComputation( person, $index) }}
18+ {{ person | heavyComputation: $index }}
819 }
920 ` ,
1021} )
1122export class AppComponent {
1223 persons = [ 'toto' , 'jack' ] ;
13-
14- heavyComputation ( name : string , index : number ) {
15- // very heavy computation
16- return `${ name } - ${ index } ` ;
17- }
1824}
You can’t perform that action at this time.
0 commit comments