0
Good afternoon,
I would like a help to pass an array of objects to a Component at angular 8.
In case I have a form that I use in two parts in my code in one of them I need this blank form and in the other I need it to be filled with bank information.
The blank is to register new services and the filled is to edit a service.
So when I call the HTML file to load this information I cannot pass this data to the Component.
I already tried with @Input, but to no avail.
Here I make the call from the app-form-service:
<ion-content>
<app-form-service></app-form-service>
</ion-content>
Here is the Component where I need to load the DB information:
<ion-content>
<form action="">
<div class="photo-container">
<img
src="https://cdn.icon-icons.com/icons2/38/PNG/512/photo_picture_4894.png"
alt="logo"
/>
</div>
<ion-item>
<ion-label>Categorias</ion-label>
<ion-select>
<ion-select-option value="01">Cabelo</ion-select-option>
<ion-select-option value="02">Pedicure</ion-select-option>
<ion-select-option value="03">Manicure</ion-select-option>
<ion-select-option value="04">Pele</ion-select-option>
<ion-select-option value="05">Sobrancelha</ion-select-option>
<ion-select-option value="06">Maquiagem</ion-select-option>
<ion-select-option value="07">Bronzeamento</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="floating">Título do serviço</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">Descrição</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">Preço</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">Tempo do serviço (em minutos)</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-button type="submit" expand="block">Cadastrar</ion-button>
</form>
</ion-content>
But you don’t use one model for that reason?
– LeAndrade
@Leandrade could show an example of how to use the model?
– Iann
Basically a model is a Javascript class (Typescript) that serves as a model (mirror) for the data returned by the Database (Api), you instance the class and can use it in forms, mirroring the data and sending the model to the database. Give a searched in the directive called Angular ngModel.
– LeAndrade
Could you share the Typescript code? On your component selectors (xml markups) I did not see the attributes to send information from the parent component (Parent) to the child (Child) using the @Input annotation.
– GILBERTO OLIVEIRA