5 lines
47 KiB
JSON

{
"id": "api/common/SlicePipe",
"title": "SlicePipe",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/common\", \"name\": \"@angular/common\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/common/SlicePipe\", \"name\": \"SlicePipe\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/common\">@angular/common</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/pipes/slice_pipe.ts?message=docs(common)%3A%20describe%20your%20change...#L11-L83\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/pipes/slice_pipe.ts#L11-L83\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"slicepipe\">SlicePipe<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#slicepipe\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label pipe\">pipe</label>\n \n \n <label class=\"api-status-label impure-pipe\">impure</label>\n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Creates a new <code>Array</code> or <code>String</code> containing a subset (slice) of the elements.</p>\n\n \n </section>\n \n \n \n<section class=\"pipe-overview\">\n <code-example hidecopy=\"true\" class=\"no-box api-heading\">{{ value_expression | <span class=\"kwd nocode\">slice</span> : start [ : end ] }}</code-example>\n\n <h2 id=\"ngmodule\">NgModule<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#ngmodule\"><i class=\"material-icons\">link</i></a></h2>\n<ul class=\"ngmodule-list\">\n\n <li>\n <a href=\"api/common/CommonModule\">\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">CommonModule</code-example>\n </a>\n </li>\n \n</ul>\n\n\n\n \n <h2 id=\"input-value\">Input value<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#input-value\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table parameters-table pipe-parameters\">\n <tbody>\n \n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>value</code>\n </td>\n <td class=\"param-type\"><code>string | readonly T[]</code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n </tbody>\n</table>\n \n \n <h2 id=\"parameters\">Parameters<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#parameters\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table parameters-table pipe-parameters\">\n <tbody>\n \n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>start</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/common/DecimalPipe\" class=\"code-anchor\">number</a></code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n <tr class=\"pipe-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>end</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/common/DecimalPipe\" class=\"code-anchor\">number</a></code></td>\n <td class=\"param-description\">\n <p>Optional. Default is <code>undefined</code>.</p>\n \n </td>\n </tr>\n </tbody>\n</table>\n \n</section>\n\n\n \n\n \n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>All behavior is based on the expected behavior of the JavaScript API <code>Array.prototype.slice()</code>\nand <code>String.prototype.slice()</code>.</p>\n<p>When operating on an <code>Array</code>, the returned <code>Array</code> is always a copy even when all\nthe elements are being returned.</p>\n<p>When operating on a blank value, the pipe returns the blank value.</p>\n<h3 id=\"list-example\">List Example<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#list-example\"><i class=\"material-icons\">link</i></a></h3>\n<p>This <code><a href=\"api/common/NgForOf\" class=\"code-anchor\">ngFor</a></code> example:</p>\n<code-example path=\"common/pipes/ts/slice_pipe.ts\" region=\"SlicePipe_list\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'slice-list-pipe',\n template: `&#x3C;ul>\n &#x3C;li *<a href=\"api/common/NgForOf\" class=\"code-anchor\">ngFor</a>=\"let i of collection | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:1:3\">{{i}}&#x3C;/li>\n &#x3C;/ul>`\n})\nexport class SlicePipeListComponent {\n collection: string[] = ['a', 'b', 'c', 'd'];\n}\n\n</code-example>\n<p>produces the following:</p>\n<code-example language=\"html\">\n&#x3C;li>b&#x3C;/li>\n&#x3C;li>c&#x3C;/li>\n</code-example>\n<h3 id=\"string-examples\">String Examples<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/SlicePipe#string-examples\"><i class=\"material-icons\">link</i></a></h3>\n<code-example path=\"common/pipes/ts/slice_pipe.ts\" region=\"SlicePipe_string\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'slice-string-pipe',\n template: `&#x3C;div>\n &#x3C;p>{{str}}[0:4]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:0:4}}' - output is expected to be 'abcd'&#x3C;/p>\n &#x3C;p>{{str}}[4:0]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:4:0}}' - output is expected to be ''&#x3C;/p>\n &#x3C;p>{{str}}[-4]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:-4}}' - output is expected to be 'ghij'&#x3C;/p>\n &#x3C;p>{{str}}[-4:-2]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:-4:-2}}' - output is expected to be 'gh'&#x3C;/p>\n &#x3C;p>{{str}}[-100]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:-100}}' - output is expected to be 'abcdefghij'&#x3C;/p>\n &#x3C;p>{{str}}[100]: '{{str | <a href=\"api/common/SlicePipe\" class=\"code-anchor\">slice</a>:100}}' - output is expected to be ''&#x3C;/p>\n &#x3C;/div>`\n})\nexport class SlicePipeStringComponent {\n str: string = 'abcdefghij';\n}\n\n</code-example>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/common\n - api/common/CommonModule\n - api/core/PipeTransform\n - guide/ajs-quick-reference\n-->\n<!-- links from this doc:\n - /api\n - api/common\n - api/common/CommonModule\n - api/common/DecimalPipe\n - api/common/NgForOf\n - api/common/SlicePipe#input-value\n - api/common/SlicePipe#list-example\n - api/common/SlicePipe#ngmodule\n - api/common/SlicePipe#parameters\n - api/common/SlicePipe#slicepipe\n - api/common/SlicePipe#string-examples\n - api/common/SlicePipe#usage-notes\n - api/core/Component\n - https://github.com/angular/angular/edit/master/packages/common/src/pipes/slice_pipe.ts?message=docs(common)%3A%20describe%20your%20change...#L11-L83\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/pipes/slice_pipe.ts#L11-L83\n-->"
}