Skip to content
@ng-doc/app / Class

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
DeclarationTypeScript
@Component({ … })
export class NgDocCodeComponent implements AfterViewInit { … }

Members

Properties

8
copyButton: InputSignal<boolean>
readonly input()

Whether the copy button is shown.

hasHeader: Signal<boolean>
readonly

Whether the header bar is shown: a block with a file name or an icon has one.

html: InputSignal<string>
readonly input()

Highlighted HTML of the code. When empty, the projected content is shown instead.

icon: InputSignal<string | undefined>
readonly input()

Name of a custom icon shown before the file name.

language: Signal<string>
protectedreadonly

Display name of the language; empty for plain text.

name: InputSignal<string | undefined>
readonly input()

File name shown in the header.

range: Signal<string>
protectedreadonly

The highlighted lines as text, for example "Lines 6–7" or "Lines 2, 5–6".

text: () => string
protectedreadonly

Reads the text of the rendered code when the copy button is pressed.

Methods

1
(): void
implements AfterViewInit

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 pre with this component after creating it.

Symbol
Kind
Class
Decorators
@Component
Selectors
ng-doc-code
Implements
AfterViewInit
Scope
@ng-doc/app
Edit this page