NgDocCodeComponent
Renders a code block: a header with the file name, the language and the highlighted lines (shown when the block has a name or an icon), line numbers and a copy button.
Line numbers are CSS counters, so they are neither copied nor announced. Setting the code-line-numbers theme variable to none hides them.
- Decorators
@Component - Selectors
ng-doc-code - Implements
AfterViewInit
@Component ({ … })
export class NgDocCodeComponent implements AfterViewInit { … }Members
Properties8 | |
copyButton: | Whether the copy button is shown. |
hasHeader: | Whether the header bar is shown: a block with a file name or an icon has one. |
html: | Highlighted HTML of the code. When empty, the projected content is shown instead. |
icon: | Name of a custom icon shown before the file name. |
language: | Display name of the language; empty for plain text. |
name: | File name shown in the header. |
range: | The highlighted lines as text, for example "Lines 6–7" or "Lines 2, 5–6". |
text: () => string | Reads the text of the rendered code when the copy button is pressed. |
Methods1 | |
(): void | Reads projected code once the view has rendered it. The page's code is projected inside a control-flow block, so it is in place only after the first render; this hook also runs on the server, so prerendered pages get the language and the highlighted lines. The page processor relies on that late projection: it replaces the page's |
Signature Returns void | |