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

131
Vistas
Is there a way to access host in a component implementing ControlValueAccessor?

By host, I understand the scope of where my component is used. If it is defined as <my-component>, then if it’s used somewhere as:

<my-component name=“Test” class=“test-class” #test=“ngModel” [(ngModel)]=“data.test” required>

then I would like to:

  • know if host component has a certain css class (i.e. test-class) applied to it.
  • get all the validators that are applied to the ngModel there (i.e. RequiredValidator)
  • know if form that ngModel belongs to has been submitted (without introducing own custom property)

For some reason, I couldn’t get to it reliably. I know of:

  • HostBinding, but that is sadly one way only and can apply classes on host, but is not updated with regards to what classes already are there
  • ElementRef injection, where I can get to nativeElement and props. That gives me classes (but very low level), but not validators / ngModel.

Is the access to ngModel “above” on the host element not allowed here?

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