0

I'm making a small app, which takes a typed message on the form, and writes it on the console.I tried to import several items, and I found problems similar to mine on the internet, but they didn't help me. I'm getting this error:

Can't bind to 'formGroup' since it isn't a known property of 'form'.

HTML:

<div class="content" role="main">
  <a>
  <form [formGroup]="pushForm"> <!--Show the error here -->
    <label>Titulo:</label>
    <input class="form-control" formControlName="titulo">
    <label>Menssagem:</label>
    <input class="form-control" formControlName="menssagem">
    <button (click)="printConsole();" >Enviar Menssagem</button>
  </form>
  </a>
</div>
<router-outlet></router-outlet>

.ts archive:

import { Component, NgModule } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
@NgModule({
  imports: [
    BrowserModule
  ],
})

  
export class AppComponent {
  pushForm = new FormGroup ({
    titulo: new FormControl(),
    mensagem: new FormControl(),
  });

  printConsole() {
    console.log("Menssagem: "+ this.pushForm);
  }

}
  • 2
    Check your module file to see if you imported `ReactiveFormsModule`, it probably comes from that. – Askirkela Feb 18 '21 at 15:06
  • Does this answer your question? [Can't bind to 'formGroup' since it isn't a known property of 'form'](https://stackoverflow.com/questions/39152071/cant-bind-to-formgroup-since-it-isnt-a-known-property-of-form) – Thibault Walterspieler Feb 18 '21 at 15:08

0 Answers0