1
I’m returning from mine API an integer, and then, with the angular need to show this value as default in this tag:
<input type="text" formControlName="pacienteId" class="form-control">
I know that to initialize forms with values of an object is used [(ngModel)]="objeto.propriedade"
but how could I return from my API that entire number using the angular service?
This is my service:
currentId(): any {
return this.http.get<number>(`${this.baseURL}/currentId`)
}
what returns from this url?
${this.baseURL}/currentId
?– adventistaam
Returns an integer number
– MenesesH3
In the Component where you call this service you can create a function to call it: ex:
currentId().then( response => this.pacienteId = response )
Ai call the function you create in the init of the Component– adventistaam
I want to show this integer number that returns from this URL every time I initialize the form
– MenesesH3
it would actually be in your form:
currentId().then( response => this.seuForm.pacienteId.setValue( response ) )
– adventistaam
Do not use codes in image, see how to ask a good question and Manual on how NOT to ask questions
– gleisin-dev