/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/examples/common/pipes/ts/slice_pipe.ts
43 строки
1 KB
Matthieu Riegler
ci: reformat files
17 дек 2025, 01:44
17 дек 2025, 01:44
6270bba
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {SlicePipe} from '@angular/common'; import {Component} from '@angular/core'; // #docregion SlicePipe_string @Component({ selector: 'slice-string-pipe', imports: [SlicePipe], template: `<div> <p>{{ str }}[0:4]: '{{ str | slice: 0 : 4 }}' - output is expected to be 'abcd'</p> <p>{{ str }}[4:0]: '{{ str | slice: 4 : 0 }}' - output is expected to be ''</p> <p>{{ str }}[-4]: '{{ str | slice: -4 }}' - output is expected to be 'ghij'</p> <p>{{ str }}[-4:-2]: '{{ str | slice: -4 : -2 }}' - output is expected to be 'gh'</p> <p>{{ str }}[-100]: '{{ str | slice: -100 }}' - output is expected to be 'abcdefghij'</p> <p>{{ str }}[100]: '{{ str | slice: 100 }}' - output is expected to be ''</p> </div>`, }) export class SlicePipeStringComponent { str: string = 'abcdefghij'; } // #enddocregion // #docregion SlicePipe_list @Component({ selector: 'slice-list-pipe', imports: [SlicePipe], template: `<ul> @for (i of collection | slice: 1 : 3; track $index) { <li>{{ i }}</li> } </ul>`, }) export class SlicePipeListComponent { collection: string[] = ['a', 'b', 'c', 'd']; } // #enddocregion