2
respostas

can't bind to ngmodel

Ao declrar [(ngModel)]="valor" essa mensagem de erro aparece. Can't bind to 'ngModel' since it isn't a known property of 'input'.ngtsc(-998002) cadastro.component.ts(5, 33): Error occurs in the template of component CadastroComponent.

2 respostas

Olá Bruna, tudo bem?


Sobre esse erro, eu acredito que você acabou esquecendo de importar o FormsModule no seu arquivo app.module.ts.

até esse momento do curso o arquivo app.module.ts está assim:


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';
import { NovaTransferenciaComponent } from './nova-transferencia/nova-transferencia.component';

@NgModule({
  declarations: [
    AppComponent,
    NovaTransferenciaComponent
  ],
  imports: [
    BrowserModule,
    FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Não esquecendo de fazer a importação do modulo próprio dele tbm: import { FormsModule } from '@angular/forms';

Espero ter ajudado, :)

import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HomeComponent } from './home/home.component'; import { MenuComponent } from './menu/menu.component'; import { ContatoComponent } from './contato/contato.component'; import { LayoutComponent } from './layout/layout.component'; import { OngsComponent } from './ongs/ongs.component'; import { FormsModule } from '@angular/forms';

@NgModule({ declarations: [ AppComponent, HomeComponent, MenuComponent, ContatoComponent, LayoutComponent, OngsComponent ], imports: [ BrowserModule, AppRoutingModule, FormsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }

Será que fiz algo errado? Achei que tivesse importado corretamente.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software