Canot find error who gives me “Can’t bind to ‘FormGroup’ since it isn’t a known property of ‘form’.” in Angular 17 [closed]

Im having this error and i cannot find where it is im following a tutorial on youtube i tried searching on google ad i get alot of examples and i tried all from adding the FormsModule with CommonModule and ReactiveFormsModule, and also tried importing it in the component ut all to no avail.

here is the component code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-create-post',
templateUrl: './create-post.component.html',
styleUrl: './create-post.component.css',
})
export class CreatePostComponent implements OnInit {
enteredTitle = '';
enteredContent = '';
forms: FormGroup | any;
private mode = 'create';
private postId: any;
public post: Post | any;
constructor(
public postService: PostServiceService,
public route: ActivatedRoute
) {}
ngOnInit() {
this.forms = new FormGroup({
title: new FormControl(null, {
validators: [Validators.required, Validators.minLength(3)],
}),
content: new FormControl(null, {
validators: [Validators.required],
}),
});
this.route.paramMap.subscribe((paramMap: ParamMap) => {
if (paramMap.has('postId')) {
this.mode = 'edit';
this.postId = paramMap.get('postId');
this.postService.getPosts(this.postId).subscribe((postData) => {
this.post = {
id: postData._id,
title: postData.title,
content: postData.content,
};
this.forms.setValue({
title: this.post.title,
content: this.post.content,
});
});
} else {
this.mode = 'create';
this.postId = null;
}
});
}
onAddPost() {
if (this.forms.invalid) {
return;
}
if (this.mode === 'create') {
this.postService.addPost(
this.forms.value.id,
this.forms.value.title,
this.forms.value.content
);
} else {
this.postService.updatePost(
this.postId,
this.forms.value.title,
this.forms.value.content
);
}
this.forms.reset();
}
}
</code>
<code>import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-create-post', templateUrl: './create-post.component.html', styleUrl: './create-post.component.css', }) export class CreatePostComponent implements OnInit { enteredTitle = ''; enteredContent = ''; forms: FormGroup | any; private mode = 'create'; private postId: any; public post: Post | any; constructor( public postService: PostServiceService, public route: ActivatedRoute ) {} ngOnInit() { this.forms = new FormGroup({ title: new FormControl(null, { validators: [Validators.required, Validators.minLength(3)], }), content: new FormControl(null, { validators: [Validators.required], }), }); this.route.paramMap.subscribe((paramMap: ParamMap) => { if (paramMap.has('postId')) { this.mode = 'edit'; this.postId = paramMap.get('postId'); this.postService.getPosts(this.postId).subscribe((postData) => { this.post = { id: postData._id, title: postData.title, content: postData.content, }; this.forms.setValue({ title: this.post.title, content: this.post.content, }); }); } else { this.mode = 'create'; this.postId = null; } }); } onAddPost() { if (this.forms.invalid) { return; } if (this.mode === 'create') { this.postService.addPost( this.forms.value.id, this.forms.value.title, this.forms.value.content ); } else { this.postService.updatePost( this.postId, this.forms.value.title, this.forms.value.content ); } this.forms.reset(); } } </code>
import { Component, OnInit } from '@angular/core';
          import { FormControl, FormGroup, Validators } from '@angular/forms';
    
@Component({
          selector: 'app-create-post',
          templateUrl: './create-post.component.html',
          styleUrl: './create-post.component.css',
           })
          export class CreatePostComponent implements OnInit {
          enteredTitle = '';
          enteredContent = '';
          forms: FormGroup | any;
          private mode = 'create';
          private postId: any;
          public post: Post | any;
    
          constructor(
          public postService: PostServiceService,
          public route: ActivatedRoute
          ) {}
    
         ngOnInit() {
        this.forms = new FormGroup({
          title: new FormControl(null, {
            validators: [Validators.required, Validators.minLength(3)],
          }),
          content: new FormControl(null, {
            validators: [Validators.required],
          }),
        });
    
        this.route.paramMap.subscribe((paramMap: ParamMap) => {
          if (paramMap.has('postId')) {
            this.mode = 'edit';
            this.postId = paramMap.get('postId');
            this.postService.getPosts(this.postId).subscribe((postData) => {
              this.post = {
                id: postData._id,
                title: postData.title,
                content: postData.content,
              };
              this.forms.setValue({
                title: this.post.title,
                content: this.post.content,
              });
            });
          } else {
            this.mode = 'create';
            this.postId = null;
          }
        });
      }
    
        onAddPost() {
        if (this.forms.invalid) {
          return;
        }
        if (this.mode === 'create') {
          this.postService.addPost(
            this.forms.value.id,
            this.forms.value.title,
            this.forms.value.content
          );
        } else {
          this.postService.updatePost(
            this.postId,
            this.forms.value.title,
            this.forms.value.content
                );
              }
              this.forms.reset();
               }
              }
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>here is the html form:
</code>
<code>here is the html form: </code>
here is the html form: 
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><mat-card>
<form [FormGroup]="forms" (submit)="onAddPost()">
<mat-form-field style="margin-top: 20px">
<mat-label>Titulo</mat-label>
<input matInput formControlName="title" />
<mat-error *ngIf="forms.get('title').invalid"
>Porfabor yena un titulo di minimo 20 karakter</mat-error
>
</mat-form-field>
<mat-form-field style="background-color: rgb(230, 227, 227)">
<mat-label>Contenido</mat-label>
<textarea matInput rows="10" formControlName="content"></textarea><br />
<mat-error *ngIf="forms.get('content').invalid"
>Porfabor yena bo contenido</mat-error
>
</mat-form-field>
<button
mat-flat-button
color="primary"
style="border-radius: 25px; width: 250px; margin: 20px 0 20px 3px"
type="submit"
>
Post
</button>
</form>
</mat-card>
</code>
<code><mat-card> <form [FormGroup]="forms" (submit)="onAddPost()"> <mat-form-field style="margin-top: 20px"> <mat-label>Titulo</mat-label> <input matInput formControlName="title" /> <mat-error *ngIf="forms.get('title').invalid" >Porfabor yena un titulo di minimo 20 karakter</mat-error > </mat-form-field> <mat-form-field style="background-color: rgb(230, 227, 227)"> <mat-label>Contenido</mat-label> <textarea matInput rows="10" formControlName="content"></textarea><br /> <mat-error *ngIf="forms.get('content').invalid" >Porfabor yena bo contenido</mat-error > </mat-form-field> <button mat-flat-button color="primary" style="border-radius: 25px; width: 250px; margin: 20px 0 20px 3px" type="submit" > Post </button> </form> </mat-card> </code>
<mat-card>
      <form [FormGroup]="forms" (submit)="onAddPost()">
        <mat-form-field style="margin-top: 20px">
          <mat-label>Titulo</mat-label>
          <input matInput formControlName="title" />
          <mat-error *ngIf="forms.get('title').invalid"
            >Porfabor yena un titulo di minimo 20 karakter</mat-error
          >
        </mat-form-field>
        <mat-form-field style="background-color: rgb(230, 227, 227)">
          <mat-label>Contenido</mat-label>
          <textarea matInput rows="10" formControlName="content"></textarea><br />
          <mat-error *ngIf="forms.get('content').invalid"
            >Porfabor yena bo contenido</mat-error
          >
        </mat-form-field>
        <button
          mat-flat-button
          color="primary"
          style="border-radius: 25px; width: 250px; margin: 20px 0 20px 3px"
          type="submit"
        >
          Post
        </button>
      </form>
    </mat-card>

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật