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

135
Visualizações
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 à 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