Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
Property 'copy' does not exist on type 'Clipboard'

I'm trying to copy a text when a button is clicked. I tried following Angular's documentation (https://material.angular.io/cdk/clipboard/overview#programmatically-copy-a-string) but my terminal is giving me the following error when compiling:

Property 'copy' does not exist on type 'Clipboard'

Here's my .ts file:

export class myComponent implements OnInit {
  constructor(private clipboard: Clipboard) {}
  ngOnInit(): void {}

  copyTest() {
    this.clipboard.copy("test"); // Property 'copy' does not exist on type 'Clipboard'.
  }
}

Here's my .html file:

<button [cdkCopyToClipboard]="copyTest()">Click to copy</button>

And here's my app.module.ts file:

import { ClipboardModule } from "@angular/cdk/clipboard";

@NgModule({
  declarations: [
    AppComponent,
    myComponent,
  ],
  imports: [
    ClipboardModule,
  ]
})

Any ideas why this error is occurring?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You must be missing the correct import for Clipboard.

Try adding: import { Clipboard } from '@angular/cdk/clipboard'; to your .ts file as well as your app.module.ts.

There is an interface Clipboard as well which your IDE probably accepts as valid TS.

over 4 years ago · Santiago Trujillo Denunciar

0

Try this instead:

<button [cdkCopyToClipboard]="copyTest('Test!')">Click to copy</button>

copyTest(test: string) {
    this.clipboard.copy(test);
  }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda