MCPcopy Create free account
hub / github.com/angular/components / _handleClick

Method _handleClick

docs/src/app/shared/doc-viewer/doc-viewer.ts:226–236  ·  view source on GitHub ↗

Copies the content of a code block when its copy button is clicked.

(event: MouseEvent)

Source from the content-addressed store, hash-verified

224
225 /** Copies the content of a code block when its copy button is clicked. */
226 protected _handleClick(event: MouseEvent) {
227 const button = (event.target as HTMLElement).closest('.docs-markdown-copy-button');
228 const code = button?.parentElement?.querySelector('code');
229
230 if (code) {
231 const message = this._clipboard.copy(code.textContent || '')
232 ? 'Copied code snippet'
233 : 'Failed to copy code snippet';
234 this._snackbar.open(message, undefined, {duration: 2500});
235 }
236 }
237
238 ngOnDestroy() {
239 this._clearLiveExamples();

Callers

nothing calls this directly

Calls 2

openMethod · 0.65
copyMethod · 0.45

Tested by

no test coverage detected