2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2016-08-16 14:15:01 -04:00
|
|
|
import {Component, NgModule} from '@angular/core';
|
|
|
|
import {BrowserModule} from '@angular/platform-browser';
|
|
|
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
2015-11-02 18:46:59 -05:00
|
|
|
|
|
|
|
// #docregion SlicePipe_string
|
|
|
|
@Component({
|
2016-09-09 00:41:09 -04:00
|
|
|
selector: 'slice-string-pipe',
|
2015-11-02 18:46:59 -05:00
|
|
|
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>`
|
|
|
|
})
|
2016-09-09 00:41:09 -04:00
|
|
|
export class SlicePipeStringComponent {
|
2015-11-02 18:46:59 -05:00
|
|
|
str: string = 'abcdefghij';
|
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion SlicePipe_list
|
|
|
|
@Component({
|
2016-09-09 00:41:09 -04:00
|
|
|
selector: 'slice-list-pipe',
|
|
|
|
template: `<ul>
|
|
|
|
<li *ngFor="let i of collection | slice:1:3">{{i}}</li>
|
|
|
|
</ul>`
|
2015-11-02 18:46:59 -05:00
|
|
|
})
|
2016-09-09 00:41:09 -04:00
|
|
|
export class SlicePipeListComponent {
|
2015-11-02 18:46:59 -05:00
|
|
|
collection: string[] = ['a', 'b', 'c', 'd'];
|
|
|
|
}
|
|
|
|
// #enddocregion
|