Hi,
I will use form group validation. But doing so " Property 'last Names' does not exist on type 'AddEditUsersComponent'." I get an error.
How can i solve this.
import { Component, OnInit,Input } from '@angular/core';
import { SharedService } from 'src/app/shared.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-add-edit-users',
templateUrl: './add-edit-users.component.html',
styleUrls: ['./add-edit-users.component.sass'],
providers:[SharedService,Kisiler]
})
export class AddEditUsersComponent implements OnInit {
constructor(private service:SharedService) { }
kisiForm=new FormGroup({
CustomerCode:new FormControl('',[Validators.required]),
email:new FormControl(''),
Password:new FormControl(''),
firstName:new FormControl(''),
lastName:new FormControl('')
});
ngOnInit(): void {
}
SaveKisi(){
this.service.addUser(this.kisiForm.value).subscribe(res=>{
alert("Kaydedildi");
alert(JSON.stringify(res));
var tok = res.token;
var toks = res.expiration;
alert(toks);
});
}
}
Kullanici Ekle
Srinivasan RamamoorthiPosted Nov 10, 2021, 2:49 PM
Sachin SinghPosted Nov 10, 2021, 2:46 PM
Ali YlmazPosted Nov 10, 2021, 1:00 PM
class
="card-title">Kullanici EkleSrinivasan RamamoorthiPosted Nov 10, 2021, 12:39 PM
the formcontrol name mentioned in view (html file) is not matching the formcontrol defined in Formgroup (model).
Keep it as lastname in both the places.
For example, lastnames is mentioned in html for formcontrol name, but in the formgroup the formcontrol name is lastname.
You have to keep the form control name same in view and model