Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Copy to clipboard from kendo textarea in Angular

I am trying to copy text from a HTML kendo textarea, I found a solution with a regular textarea but unable to implement the solution with a kendo-textarea:

https://stackblitz.com/edit/angular-mvfpr6?embed=1&file=src/app/app.component.html

When I try to implement the same for kendo textarea it throws the below error: inputElement.select is not a function

My stackblitz app: https://stackblitz.com/edit/angular-7zcv4o?file=app/app.component.ts

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're very close in your solution. In the copyInputMessage method, set the type of inputElement to be TextAreaComponent. The API documentation of the component can be found here: https://www.telerik.com/kendo-angular-ui/components/inputs/api/TextAreaComponent

After you specify the type, get the input field from the component and get the nativeElement property of the input. With this value, you can call select and setSelectionRange.

Here is an example:

public copyInputMessage(inputElement: TextAreaComponent) {
  const elementRef = inputElement?.input?.nativeElement;
  if (!elementRef) {
    return;
  }
  elementRef.select();
  document.execCommand('copy');
  elementRef.setSelectionRange(0, 0);
}

Example: https://stackblitz.com/edit/angular-7zcv4o-iddki1

FYI - It might be worth opening a "success" toast at the end of the method to indicate to the user that the text was copied.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda