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

215
Vistas
ngmodel not working in child component for on push change detection

I am creating my custom component, suppose api response is late(here I reproduced problem with setTimeOut()), then my ngModel is not updating until I select that component, I am using ChangedetectionStratagy OnPush

Here I am attaching stackblitz link directly . Please help

https://stackblitz.com/edit/primeng-dropdown-demo-2t9ed3?file=src/single-select/single-select.component.ts

It is working fine when I am making ChangedetectionStratagy.Default

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Well since you are using onPush change detection strategy you have to trigger the change detection manually . with onPush the change detection is not trigger until component input changes. here is how you trigger it manually in your AppComponent

export class AppComponent implements OnInit {
 constructor(private cf: ChangeDetectorRef) {} // insert changeDetectorRef
  ngOnInit() {
   setTimeout(() => {
    this.selectedModel = 'CN';
    this.cf.markForCheck() // line added
   }, 2000);
  }

https://stackblitz.com/edit/primeng-dropdown-demo-jbzchf?file=src/single-select/single-select.component.html

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