doubts firebase with Ionic (ion-select)

Asked

Viewed 366 times

1

I have an application, and I want to know how to insert information into the firebase database and then put this data inside a ion-select, my application uses a select of professions such as: "mechanic", "bricklayer", "teacher" and etc, and I want this to stay within a ion-option of ion-select, but I don’t know how to do it. I did it like this in my code:

<ion-select [(ngModel)]="profissoes1" okText="Salvar" cancelText="Cancelar">
    <ion-option *ngFor="let items of items">{{items}}</ion-option>
  </ion-select>

and I want a tip on how to use typescript, to get firebase professions to take the place of {{items}}, and how to insert the professions in firebase as well

1 answer

1

In this link there is a firebase tutorial, for sure will help you.

This another link refers to ion-select documentation.

The advantage of using Firebase is that you don’t need to encode the back end. However, before making the requests, you have to remember to change the default authorization to release these requests to other users. Received the result of this request, what you have to do is store it in a variable and iterate (repeat) with *Ngfor and pass the value and name shown, example:

<ion-select [(ngModel)]="data.person" multiple>
  <ion-option *ngFor="let name of namesList" [value] = "name.firstName" [checked]="false">{{name.firstName}}</ion-option>
</ion-select>

In this example, it is understood that you have stored the result of the request in the variable namesList and for each item, you call "name", and to access the attributes of this object, use the name of the object (name) followed by the name of the attribute (firstName), getting 'name.firstName'

  • is that I’m really lost in ion-select, and in firebase I just push and take the data by reference, but in this situation, I want the information to be entered manually in the database and stay inside the ion-option

  • Right, to add data manually to your Firebase database, see this link. To populate your ion-options with the data coming from the database, you have to assemble a service that makes a request bringing the data of this route (/users, for example), and return this precedent to your page, and finally, assign this precedent in the attribute that will be in ng-model

Browser other questions tagged

You are not signed in. Login or sign up in order to post.