I have a form which has to be submitted after checking form validations. But when I submit the form it does not to make a request to API.
my component.html file
<form
class="forms"
[formGroup]="addContainerForm"
(ngSubmit)="addAnalyticsSubmit(addContainerForm.value)"
>
// some code
</form>
my component.ts file
addContainerForm(v){
this.new = v
const a = {
Name: this.new.nameValue,
Coordinates: this.coordinates,
};
if (this.addContainerForm.valid) {
this.service.postContainer(a).subscribe(
(res: any) => {
console.log(res)})
}
}
I don't know why API is not hit when the check condition is applied for form validation. Please, tell me what I am doing wrong.