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.
JavaScript
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);
});
}
}Code
Kullanici Ekle
Customer Code
Zorunlu
Email address
Zorunlu
Password
Zorunlu
First Name
Zorunlu
Last Name
Zorunlu
Register
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 10, 2021, 7:39 AM EST
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
Ali Ylmaz151 reputationPosted Nov 10, 2021, 8:00 AM EST
class
="card-title">Kullanici EkleSachin SinghRank #66 · 26.2K reputationPosted Nov 10, 2021, 9:46 AM EST
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 10, 2021, 9:49 AM EST