Populating a select with Angular2 and Firebase

Asked

Viewed 277 times

0

blz? I’m starting in Angular2 and I’m finding Firebase a much better backend than Backand, because in a very short time I was able to connect to Firebase. The point now is, I’m trying to popular a select but it’s coming without the names. Comes four items, but empty. Let’s go to the HTML code

<label>Escolha a marca</label>
<select materialize="material_select" [materializeSelectOptions]="selectOptions" class="browser-default">
  <option  *ngFor="let marca of marcas | async">{{ nome }}</option>
</select>

And now an image of the Firebase bank

inserir a descrição da imagem aqui

Someone who knows enough to give me a hand? Thanks a lot, hugs!

  • You tested brand name. ?

  • No, good idea!

2 answers

0

But now it is returning the due array. Only inside each brand, you have an object {logo, name}.

You need to access the target string brand name.:

<option  *ngFor="let marca of marcas | async">{{ marca.nome }}</option>

0


I had this same problem, but I managed to solve it. I hope I can help you.

The component must be iterated with the list defined in [materializeSelectOptions]="selectOptions". Then, in your case, just use [materializeSelectOptions]="tags" (which is the asynchronous array that will be traversed).

Already the options are:

{{ brand name. }}

  • Something has really changed, but it hasn’t worked yet! <select _ngcontent-Rdx-4="" class="browser-default" materialize="material_select" ng-reflect-materialize="material_select" ng-reflect-materialize-select-options="[Object Object]"> <!-template bindings={&#xA; "ng-reflect-ng-for-of": "[object Object],[object Object],[object Object],[object Object]"&#xA;}--><option _ngcontent-rdx-4=""></option><option _ngcontent-rdx-4=""></option><option _ngcontent-rdx-4=""></option><option _ngcontent-rdx-4=""></option>&#xA;</select>&#xA;&#xA;Note os [Object Object]

Browser other questions tagged

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