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

321
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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