Level 34
Mar 10, 2021
3
Level 1
oh really?"Property 'form' has no initializer and is not definitely assigned in the constructor. (property) CreateComponent.form: FormGroup"
i know this forum dont support Angular. but i have issue in this. i got this text
Property 'form' has no initializer and is not definitely assigned in the constructor. (property) CreateComponent.form: FormGroup
in my web but i cant find solution for this. btw thanks
import { Component, OnInit } from '@angular/core';
import { ProductService } from '../../Services/product.service';
import { Router } from '@angular/router';
import { FormGroup, FormControl, Validators } from '@angular/forms';
@Component({
selector: 'app-create',
templateUrl: './create.component.html',
styleUrls: ['./create.component.css']
})
export class CreateComponent implements OnInit {
form: FormGroup;
constructor(public ProductService: ProductService) {
}
ngOnInit(): void {
this.form = new FormGroup({
tite: new FormControl('',[Validators.required]),
body: new FormControl('',[Validators.required])
});
}
get f() {
return this.form.controls;
}
}
Please or to participate in this conversation.