I am not understanding how to do
- console.log of a specific value
- display in a label on HTML page
- display in an input text
Here is my Component Typescript with new FormGroup and then the new FormControls
this.trackerForm = new FormGroup({
session: new FormControl('', Validators.required),
date: new FormControl(new Date(), [
Validators.required
]),
contactType: new FormControl('', [
Validators.required
]),
customerType: new FormControl('', Validators.required),
firstName: new FormControl('', [Validators.required, Validators.minLength(80)]),
lastName: new FormControl('', [Validators.required, Validators.minLength(80)]),
phone: new FormControl('', [Validators.required, Validators.maxLength(10), Validators.minLength(10)]),
extension: new FormControl('', [Validators.maxLength(7)])
});
// this outputs the entire json
console.log(JSON.stringify(this.trackerForm.value));
//How do I ONLY console.log one of the values? date?
HTML on page -
<form [formGroup]="trackerForm" (ngSubmit)="onSubmit(trackerForm.value)" novalidate>
<div>
<label class="form-control"><span>{{trackerForm.date.value}} </span></label>
</div>
<label class="form-control"><span>{{trackerForm.value.date | date:'short'}} </span></label>
– Rajezconsole.log(this.trackerForm.get('fieldName').value);
– Antoine Clavijo{{trackerForm.get('fieldName').value}}
– Antoine Clavijo