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

320
Vistas
Ant - Can't bind to 'ngModel' since it isn't a known property of 'nz-switch'

I'm using Ant Design for Angular (ng-zorro-antd), and using the simple switch module to display a switch.

When I add the code per the docs:

<nz-switch [ngModel]="true"></nz-switch>

The app won't compile, and I get this error:

Can't bind to 'ngModel' since it isn't a known property of 'nz-switch'

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

0

Import FormsModule in the right module

While it doesn't say it in the documentation, you need to have Angular's FormsModule imported in order for the ngModel binding to work.

If you have an app with just one module, this is easy. Simply import the FormsModule as below in your one and only xxx.module.ts file.

If you're working on an app with multiple modules, as I was, you have to ensure you're importing it in the module where you're going to use the nz-switch

In that module, where you're using the nz-switch, in the xxx.module.ts file:

import { FormsModule } from '@angular/forms`;

... 

@NgModule({
  declaration: [ ... ],
  imports: [ 
    ...,
    FormsModule
  ],
  ...

You should be good to go.

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