As I delve into learning Angular, I am focused on practicing with a form. Specifically, I am attempting to include the current date when inputting client records along with their RFC, branch, and cost. Unfortunately, my attempts have been unsuccessful in injecting the date into the database. Since I am a beginner with Angular, I kindly ask for guidance without unnecessary comments that don't add to the solution:
This is the code snippet from my component:
export class ClientAddEditComponent implements OnInit {
form: FormGroup;
loading: boolean = false;
id: number;
operacion: string = 'Agregar ';
replace_fec : string = new Date().toISOString();
// constructor and other methods here...
}
The `Client` interface used in the component looks like this:
export interface Client{
id?: number;
datesuscribe: string;
namefact: string;
rfcfact: string;
sucfact: string;
pricefact: Number
}
This is an excerpt from my service:
@Injectable({
providedIn: 'root'
})
export class ClientService {
private myAppUrl: string;
private myApiUrl: string;
// Constructor and other methods here...
}
I attempted to save the current date as a string in the `replace_fec` variable, but it seems like there might be an issue with how I'm handling it since other fields get inserted while this one doesn't. The field in the MySQL database is configured as a varchar(50).