Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
Angular - Texto de entrada claro al hacer clic en "x"

Tengo un campo de entrada donde el usuario puede ingresar texto. Tengo un símbolo x a la izquierda del campo de entrada. Estoy tratando de borrar el texto cuando se hace clic en el símbolo, pero no puedo hacerlo. También input tfFormInput es texto personalizado de la biblioteca npm

Intenté usar ngModel pero no funcionó para mí

¿Qué debo agregar en el método de remove para que funcione? ingrese la descripción de la imagen aquí

 <div class="placeholder"><input tfFormInput /> </div> <div class="im-target-param-row-delete" (click)="remove()" [(ngModel)]="searchValue"> <div class="close-ctnr"> <svg viewBox="0 0 10 10"> <line x1="1" y1="1" x2="9" y2="9"/> <line x1="1" y1="9" x2="9" y2="1"/> </svg> </div> </div>

.ts

 export class SearchComponent implements OnInit { searchValue:string = ''; removeSelectedSpecification(){ this.searchValue = ''; } }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

NgModel debe estar en la entrada como se muestra a continuación.

 <div class="placeholder"><input tfFormInput [(ngModel)]="searchValue"/> </div> <div class="im-target-param-row-delete" (click)="remove()"> <div class="close-ctnr"> <svg viewBox="0 0 10 10"> <line x1="1" y1="1" x2="9" y2="9"/> <line x1="1" y1="9" x2="9" y2="1"/> </svg> </div> </div> remove() { this.searchValue = ''; }
about 4 years ago · Juan Pablo Isaza Report

0

podrías intentar algo como esto. mueva el valor de búsqueda al elemento de entrada.

 @Component({ selector: 'my-app', template: ` <div> <input type="text" placeholder="Search..." [(ngModel)]="searchValue"> <button (click)="clearSearch()">Clear</button> </div> `, }) export class App { searchValue:string = null; clearSearch() { this.searchValue = ''; console.log(this.searchValue.length, this.searchValue, typeof(this.searchValue)); } }
about 4 years ago · Juan Pablo Isaza Report

0

intenta así:

archivo HTML:

 <div> <input type="text" placeholder="Search..." [(ngModel)]="searchValue"> <button (click)="remove()">X</button> </div>

archivo ts:

 export class SearchComponent implements OnInit { searchValue:string = ''; remove(){ this.searchValue = ''; } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!