# कस्टम पाइप्स — एंगुलर

Source: https://www.geekswithgeeks.com/hi/angular/ng-custom-pipes

> अपना खुद का ट्रांसफॉर्मेशन लॉजिक एक पुनः-उपयोगी पाइप के रूप में लिखें।

## @Pipe और transform

कस्टम पाइप `PipeTransform` को implement करता है; `transform` मेथड इनपुट मान और कोई भी तर्क लेता है और बदला हुआ परिणाम लौटाता है।

```typescript
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'truncate', standalone: true })
export class TruncatePipe implements PipeTransform {
  transform(value: string, limit = 20): string {
    return value.length > limit ? value.slice(0, limit) + '…' : value;
  }
}
```

## इसका उपयोग

पाइप को स्टैंडअलोन कंपोनेंट में import करें, फिर इसे `|` के साथ किसी बिल्ट-इन पाइप की तरह उपयोग करें।

```html
<p>{{ article.summary | truncate:80 }}</p>
```
