/** * @license * Copyright Google Inc. 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.io/license */ import {Component, NgModule} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; // #docregion SlicePipe_string @Component({ selector: 'slice-string-example', template: `

{{str}}[0:4]: '{{str | slice:0:4}}' - output is expected to be 'abcd'

{{str}}[4:0]: '{{str | slice:4:0}}' - output is expected to be ''

{{str}}[-4]: '{{str | slice:-4}}' - output is expected to be 'ghij'

{{str}}[-4:-2]: '{{str | slice:-4:-2}}' - output is expected to be 'gh'

{{str}}[-100]: '{{str | slice:-100}}' - output is expected to be 'abcdefghij'

{{str}}[100]: '{{str | slice:100}}' - output is expected to be ''

` }) export class SlicePipeStringExample { str: string = 'abcdefghij'; } // #enddocregion // #docregion SlicePipe_list @Component({ selector: 'slice-list-example', template: `
  • {{i}}
  • ` }) export class SlicePipeListExample { collection: string[] = ['a', 'b', 'c', 'd']; } // #enddocregion @Component({ selector: 'example-app', template: `

    SlicePipe Examples

    ` }) export class AppCmp { } @NgModule({imports: [BrowserModule], bootstrap: [AppCmp]}) class AppModule { } export function main() { platformBrowserDynamic().bootstrapModule(AppModule); }