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

87
Views
¿Por qué necesitamos tener dos ID iguales en componente de alerta y servicio de alerta?

Estoy tratando de implementar alertas en mi página web. He encontrado algunas guías que explican cómo crear alertas en angular. La mayoría de ellos lo están implementando de la misma manera, lo que me hace creer que es el camino a seguir. Lo que no entiendo es que todas esas guías tienen una identificación en alertComponent con la anotación @input

Alert-component.ts

@Input() id = 'default-alert';

Luego llamamos al método onAlert y proporcionamos la identificación como argumento

this.alertSubscription = this.alertService.onAlert(this.id)

La clase alert-service.ts también tiene un campo llamado defaultId con el mismo valor que alert-component

alerta-servicio.ts

private defaultId = 'default-alert';

Luego, en la implementación del método OnAlert en el servicio de alerta, tomamos la identificación que recibimos como argumento y la asignamos a la identificación predeterminada. ¿Es esto algo común en angular? no entiendo

 onAlert(id = this.defaultId): Observable<Alert> { return this.subject.asObservable().pipe(filter(x => x && x.id === id)); }

Agradecería sus respuestas para ayudarme a entender. ¡Gracias!

about 4 years ago · Juan Pablo Isaza
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!