Custom Pipes: When a custom pipe is created, It must be registered in Module and Component that is being used.
export class SummaryPipe implements PipeTransform{
//Implementing transform
transform(value: string, limit?: number): any {
if (!value) {
return null;
}
else {
let actualLimit=limit>0?limit:50
return value.substr(0,actualLimit)+'...'
}
}
}
Add Pipe Decorator
@Pipe({
name:'summary'
})
and refer
import { SummaryPipe } from '../summary.pipe';` //**In Component and Module**
<div>
**{{text | summary}}** //Name should same as it is mentioned in the decorator.
</div>
//summary is the name declared in Pipe decorator