i\'m learning AngularJS, and i need some help.
I have a template like this
this.data = dataFromSomewhere();
this.dataOpt = this.data.map((d) => this.myFunction(d.id));
{{dataOpt[i]}}
The pipe variant:
@Pipe({selector: myFunc})
class MyPipy implements PipeTransform {
transform(val:string) {
return // do the same calculation here that you would do in `myFunction`;
}
}
and use it like
{{data | myPipe}}
(the pipe needs to be registered in declarations of the module (or in an imported module)