InterviewHubPRO
Section Overview
Q202

Question 202 of 283

Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

71%
Angular & Signals (283 Qs)•Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

What is slice pipe?

The slice pipe is used to create a new Array or String containing a subset (slice) of the elements. The syntax looks like as below,

javascript
{{ value_expression | slice : start [ : end ] }}

For example, you can provide 'hello' list based on a greeting array,

javascript
@Component({
selector: 'list-pipe',
template: `<ul>
  <li *ngFor="let i of greeting | slice:0:5">{{i}}</li>
</ul>`
})
export class PipeListComponent {
greeting: string[] = ['h', 'e', 'l', 'l', 'o', 'm','o', 'r', 'n', 'i', 'n', 'g'];
}